pg_shadow is only accessible by the superuser. Pg_user is the view created on the base table pg_shadow table, which is available publicly. This table stores the roles that can log in and flag rolcanlogin as 1 in the pg_authid table. The table is maintained for backward compatibility with PostgreSQL versions earlier than 8.1. One more way to get the list of the users is by using the table pg_shadow, that also contains information about the users in the PostgreSQL server. WHEN u.usesuper THEN CAST('Superuser' AS pg_catalog.text) WHEN u.usecreatedb THEN CAST('Create DB' AS pg_catalog.text)ĮLSE CAST('' AS pg_catalog.text) END AS "Attributes"įROM pg_catalog.pg_user u ORDER BY 1 3. The query which internally gets fire after using \du metacommand is somewhat similar to the below query statement:ĬASE WHEN u.usesuper AND u.usecreatedb THEN CAST('Create DB, Superuser' AS pg_catalog.text) At the same time, a field member tells us if the user is a member of any particular group if present. Here, we get the role name as the user’s name, and a list of role attributes helps us to know which privileges are granted to that particular user.
0 Comments
Leave a Reply. |