![]() ![]() A role that can login is equivalent to a user acocunt in other database systems. PostgreSQL uses roles to represent user accounts.Postgres | Superuser, Create role, Create DB, Replication, Bypass RLS | Code language: Shell Session ( shell ) Summary \du Code language: PostgreSQL SQL dialect and PL/pgSQL ( pgsql ) ![]() If you use the psql tool, you can use the \du command to list all existing roles in the current PostgreSQL database server. Noice that the roles that start with with pg_ are system roles. To get all roles in the current PostgreSQL database server, you can query them from the pg_roles system catalog as follows: SELECT rolname FROM pg_roles Code language: PostgreSQL SQL dialect and PL/pgSQL ( pgsql )īob Code language: PostgreSQL SQL dialect and PL/pgSQL ( pgsql ) The following statement uses the CREATE ROLE statement to create a new role called bob: CREATE ROLE bob Code language: PostgreSQL SQL dialect and PL/pgSQL ( pgsql ) When you create a role, it is valid in all databases in the database server (or cluster). To create a new role, you use the CREATE ROLE statement as follows: CREATE ROLE role_name Code language: PostgreSQL SQL dialect and PL/pgSQL ( pgsql ) Note that PostgreSQL combined the users and groups into roles since version 8.1 PostgreSQL CREATE ROLE statement When roles contain other roles, they are call group roles. They are equivalent to users in other database systems. Typically, roles can log in are called login roles. It doesn’t use the user concept like other database systems. PostgreSQL uses roles to represent user accounts. ![]()
0 Comments
Leave a Reply. |