我正在进行数据库服务器迁移,我无法计算(在这里搜索和搜索之后)如何使用PostgreSQL命令行工具列出psql上的数据库特权(或整个服务器上的所有特权)?
我在Ubuntu11.04上,我的PostgreSQL版本是8.2.x。
发布于 2011-08-04 08:24:23
postgres=> \l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-----------+----------+----------+-------------+-------------+-----------------------
postgres | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
template0 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
template1 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres特权文件解释了如何解释输出。对于当前数据库表上的特定权限,请使用\z myTable。
发布于 2016-10-18 07:11:18
你可以这样做:
SELECT grantee, privilege_type
FROM information_schema.role_table_grants
WHERE table_name='mytable'这给出了这样的输出:
mail=# select grantee, privilege_type from information_schema.role_table_grants where table_name='aliases';
grantee | privilege_type
--------------+-----------------
mailreader | INSERT
mailreader | SELECT
mailreader | UPDATE
mailreader | DELETE
mailreader | TRUNCATE
mailreader | REFERENCES
mailreader | TRIGGER
(7 rows)
mail=#发布于 2011-08-04 15:59:53
也许您的意思是列出用户及其对数据库的权限--从这个问题上我看不出来:
postgres=> \du
List of roles
Role name | Attributes | Member of
-----------------+--------------+------------------------------------------------
dba | Create role | {util_user,helpdesk_user,helpdesk_admin}
helpdesk_admin | Cannot login | {helpdesk_user}
helpdesk_user | Cannot login | {helpdesk_reader}
jack | | {helpdesk_admin}
postgres | Superuser | {}
: Create role
: Create DBhttps://dba.stackexchange.com/questions/4286
复制相似问题