Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Display default access privileges for relations, sequences and functions in Postgres

After altering the default privileges on a Postgres database object, how can you view them?

For instance, if you grant all privileges to role_name for all tables created in the schema schema_name:

ALTER DEFAULT PRIVILEGES IN SCHEMA schema_name GRANT ALL ON TABLES TO role_name; 
like image 723
Clint Pachl Avatar asked Jan 28 '13 03:01

Clint Pachl


People also ask

How do I check access privileges in PostgreSQL?

Another way to do this is to use the information_schema schema and query the table_privileges table as: $ SELECT * FROM information_schema. table_privileges LIMIT 5; The above query will show detailed information about user privileges on databases as well as tables.

What are default privileges in Postgres?

No privileges are granted to PUBLIC by default on tables, columns, schemas or tablespaces. For other types, the default privileges granted to PUBLIC are as follows: CONNECT and CREATE TEMP TABLE for databases; EXECUTE privilege for functions; and USAGE privilege for languages.

What is usage privileges in PostgreSQL?

The view usage_privileges identifies USAGE privileges granted on various kinds of objects to a currently enabled role or by a currently enabled role. In PostgreSQL, this currently applies to collations, domains, foreign-data wrappers, foreign servers, and sequences.


1 Answers

Using the psql(1) interactive terminal

There is another way, at least in recent Postgres versions.
Use the \ddp command

               Default access privileges      Owner      | Schema |   Type   | Access privileges  ----------------+--------+----------+-------------------  role_x         |        | function | =X/role_x  role_x         |        | sequence |   role_x         |        | table    |   role_x         |        | type     | =U/role_x 

Read more about it under the Notes section here:
http://www.postgresql.org/docs/current/static/sql-alterdefaultprivileges.html

like image 118
Zyphrax Avatar answered Sep 17 '22 14:09

Zyphrax