Consultando usuários de um banco PostgreSQL

Consultando todos os usuários de um banco PostgreSQL

SELECT usename AS role_name,
  CASE 
     WHEN usesuper AND usecreatedb THEN 
       CAST('superuser, create database' AS pg_catalog.text)
     WHEN usesuper THEN 
        CAST('superuser' AS pg_catalog.text)
     WHEN usecreatedb THEN 
        CAST('create database' AS pg_catalog.text)
     ELSE 
        CAST('' AS pg_catalog.text)
  END role_attributes
FROM pg_catalog.pg_user
ORDER BY role_name desc;

Listando Usuários e Grupos:

SELECT groname,usename from pg_group,pg_user where usesysid = any(grolist);

Listando Usuários e seus Schemas

select nspname,tablename from pg_tables, pg_namespace where nspname not similar
to '%(pg_|information_schema)%' and nspname = schemaname;

 

Leave a Reply

Your email address will not be published. Required fields are marked *