DBAtlas · Database operations atlas

Show a user's privileges

Oracle

SELECT privilege FROM dba_sys_privs WHERE grantee = 'APP'
UNION ALL SELECT granted_role FROM dba_role_privs WHERE grantee = 'APP'
UNION ALL SELECT privilege||' ON '||owner||'.'||table_name
          FROM dba_tab_privs WHERE grantee = 'APP';

The grantee is stored in uppercase. For indirect privileges granted through roles, also walk role_role_privs.

PostgreSQL

SELECT grantee, table_schema, table_name, privilege_type
FROM information_schema.role_table_grants
WHERE grantee = 'app';
-- Role memberships (direct): \drg app (PG16+; earlier \du app)

Role memberships (inheritance) are stored in pg_auth_members; \du/\drg show only direct memberships, use pg_has_role('app', '<role>', 'MEMBER') for indirect membership.

MySQL

SHOW GRANTS FOR 'app'@'%';

For roles (MySQL 8), first SET ROLE ALL, or use SHOW GRANTS FOR 'app'@'%' USING 'role_name';

SQL Server

SELECT dp.name AS principal, p.permission_name,
       p.state_desc, o.name AS object
FROM sys.database_permissions p
JOIN sys.database_principals dp ON p.grantee_principal_id = dp.principal_id
LEFT JOIN sys.objects o ON p.major_id = o.object_id
WHERE dp.name = 'app';

For permissions granted through roles, also check memberships in sys.database_role_members.

MongoDB

db.getUser("app", { showPrivileges: true, showCredentials: false })

showPrivileges also lists the expanded (effective) privileges of the roles.

Redis

ACL GETUSER app

Returns the allowed commands, key patterns (~), pub/sub channels (&) and password hashes.

Open in DBAtlas →