PostgreSQL - How to list all privileges on a specific database?
How to list all privileges granted on a specific PostgreSQL database?
1. Using sql:
postgres=> \l
It lists all the databases from the current connection along with their names, owners, character set encodings, and access privileges.
You can try this \du
command to lists database roles.
You can also use \dp
to list tables, views and sequences with their associated access privileges.
2. Using SQL Query:
Run this query:
SELECT
grantee,
privilege_type
FROM
information_schema.role_table_grants
WHERE
table_name = 'table_name';
For example:
SELECT
grantee,
privilege_type
FROM
information_schema.role_table_grants
WHERE
table_name = 'actor';
Need a good GUI Tool for PostgreSQL? TablePlus is a modern, native tool with an elegant UI that allows you to simultaneously manage multiple databases such as MySQL, PostgreSQL, SQLite, Microsoft SQL Server and more.