This will output all users, including their login username, roles, and whether they have administrative rights. List all PostgreSQL Roles List all roles in PostgreSQL with the following command: \dg This will output a list of all roles, including the name of the role and the names of the u...
List of roles Role name | Attributes | Member of ---+---+--- postgres | Superuser, Create role, Create DB, Replication, Bypass RLS | {} ubuntu | | {} postgres=# \du+; List of roles Role name | Attributes | Member of | Description ---+---+---...
List of roles Role name | Attributes | Member of ---+---+--- david | | {} postgres | Superuser, Create role, Create DB, Replication | {} sandy | | {} postgres=# SELECT rolname from pg_roles ; rolname --- postgres sandy david (3 rows) postgres=# SELECT usename from pg_use...
postgres=#CREATEROLEadminCREATEDBCREATEROLE;CREATEROLEpostgres=#\duListofrolesRolename|Attributes|Memberof---+---+---admin|Createrole,CreateDB,Cannotlogin|{}postgres|Superuser,Createrole,CreateDB,Replication,BypassRLS|{}tony|Passwordvaliduntil2020-01-0100:00:00-05|{} 在实践中,最好创建一个拥有 CRE...
select rolname from pg_roles ; rolname --- postgres pg_monitor pg_read_all_settings pg_read_all_stats pg_stat_scan_tables pg_read_server_files pg_write_server_files pg_execute_server_program pg_signal_backend (9 rows) Time: 0.955 ms 1. 2. ...
方式1: 在系统命令行中使用createuser命令中创建 Create user username 方式2: 在PostgresSQL命令行中使用CREATE ROLE指令创建 CREATE ROLE rolename; [postgres@abc ~]$ createuser lss [postgres@abc ~]$ psql psql (11.2) Type "help" for help. postgres-# \du List of roles Role name | Attributes |...
List of roles Role name | Attributes | Member of ---+---+--- lss | | {} postgres | Superuser, Create role, Create DB, Replication, Bypass RLS | {} 授权 postgres=# alter role lss Createrole CREATEDB; ALTER ROLE postgres=# \du List of roles Role name | Attributes...
test-# \dgList of rolesRole name | Attributes | Member of---+---+---pg1 | Superuser, Create role, Create DB, Replication, Bypass RLS | {}postgres | Superuser | {}postgres_exporter | | {}postgres_exporter1 | | {}zsk | | {}test-# \dg+List of rolesRole name | Attributes |...
以表为例,基本的授权语法如下:GRANT privilege_list | ALL ON [ TABLE ] table_name TO role_name;其中,privilege_list 权限列表可以是 SELECT、INSERT、UPDATE、DELETE、TRUNCATE 等,ALL 表示表上的所有权限。例如,以下语句将 employees、departments 和 jobs 表上的增删改查权限授予了 tony 用户:...
| | \du[+] [pattern] | List roles. | | \dv[+] [pattern] | List views. | | \dx[+] [pattern] | List extensions. | | \e [file] | Edit the query with external editor. | | \h | Show SQL syntax and help. | | \i filename | Execute commands from file. | | \l[+] ...