A two-line audit for a database you've just inherited, or for a quarterly access review: which accounts can log in right now and hold the DBA role.
Usage
SQL> @dba.sql
-- dba.sql: open accounts granted the DBA role
-- Copyright (c) HASHJOIN. MIT License (https://hashjoin.com/kb/license/)
-- https://hashjoin.com/kb/oracle/open-accounts-with-dba-role/
--
-- Usage: @dba.sql
select grantee,ACCOUNT_STATUS
from dba_role_privs p
, dba_users u
where granted_role='DBA'
and p.grantee = u.USERNAME
and u.ACCOUNT_STATUS = 'OPEN'
order by 1;curl -O https://hashjoin.com/kb/oracle/open-accounts-with-dba-role/dba.sql
Gotchas
- Only direct grants are listed. An account granted a custom role that itself holds DBA won't show up; query
dba_role_privsrecursively if you use nested roles. - DBA isn't the only way in. Also check
SYSDBAandSYSOPERholders (v$pwfile_users) and powerful system privileges such asGRANT ANY PRIVILEGEorALTER USER(dba_sys_privs). - Locked and expired accounts are left out on purpose (
account_status = 'OPEN').
What it reads
Tired of fixing the same thing twice?
HASHJOIN turns the checks and fixes your on-call runs by hand into tooling that gives the same answer every time. Fixed scope, and you own all of the code.
New fixes and field notes by email, about once a month.