KB · Oracle Database · Script

List open accounts that have the DBA role

Oracle Database · Script · Verified on Oracle 11.2 and 23ai · Updated 2026-12-03

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.sqlMIT · Download ·
-- 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

What it reads

dba_role_privs dba_users

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.