Goal Find the privileges to use the database. c - CONNECT; C - CREATE; T - TEMPORARY.
Type General (Overview of some aspect of the database.)
License MIT License
Data Source system catalog only
SQL Query
WITH db_privs AS (SELECT unnest(datacl)::text AS priv  
FROM pg_database
WHERE datname=current_database()), 
privs_extracted AS (SELECT 
left(priv, (position('=' IN priv)-1)) AS grantee,
substring(priv, position('=' IN priv)+1, position('/' IN priv)-position('=' IN priv)-1) AS privileges
FROM db_privs)
SELECT CASE WHEN grantee='' THEN 'PUBLIC' ELSE grantee END AS grantee, 
usesuper AS is_grantee_superuser, privileges
FROM privs_extracted LEFT JOIN pg_user ON privs_extracted.grantee=pg_user.usename
ORDER BY grantee;

Collections

This query belongs to the following collections:

NameDescription
Find problems by overviewQueries that results point to different aspects of database that might have problems. A human reviewer has to decide based on the results as to whether there are problems or not .
Categories

This query is classified under the following categories:

NameDescription
SecurityQueries of this category provide information about the security measures.