
How to list database privileges in PostgreSQL
Sun, 03 Jan 2021
When creating a new database in PostgreSQL or when creating a new connection to an existing database from a new client, it is recommended that a dedicated database user is used.
Each database user must only be granted the permissions needed to solve it's purpose.
The following SQL command allows you to obtain the current PostgreSQL privileges configured in the active database:
SELECT grantee, table_name, privilege_type
FROM information_schema.role_table_grants
This command will output some like:
grantee | Table_name | privilege_type |
---|---|---|
management_username | users | INSERT |
management_username | users | SELECT |
management_username | users | UPDATE |
management_username | users | DELETE |
management_username | users | TRUNCATE |
management_username | users | REFERENCES |
management_username | users | TRIGGER |
statistics_username | sessions | SELECT |
Sample Privileges
However, you may only execute this SQL and get the PostgreSQL privileges as an admin user.
Categories: how-to, mysql, postgresql