top of page

Oracle Database Vault Realms: Stopping DBAs from Reading Application Data

OmerNarman
Aug 27
10 min read

Updated: Oct 24

Privilege is the problem Database Vault solves. A DBA with SELECT ANY TABLE can read every customer record in the database, and nothing in standard Oracle security stops that, because the privilege is doing exactly what it says. Auditing records the access after the fact, but it does not prevent it.


Oracle Database Vault puts a boundary around application data that even the DBA role and SYS cannot cross, and it turns every attempt into an audit record. This post enables Database Vault in a 19c container database, protects an application schema with a realm, tests it safely in simulation mode, enforces it, and covers the operational changes (patching, Data Pump, scheduler jobs) that keep the DBAs productive.



The Use Case

An application schema, APP, holds customer and payment data in the PDB SALESPDB. The requirements are:


  • The DBAs keep running the database: patching, backups, performance, storage.

  • The DBAs must not be able to read, change or drop APP objects.

  • The application's runtime account must keep working unchanged.

  • Changes to APP tables are allowed only in the Sunday change window.

  • Auditors need proof that the boundary is enforced, not just intended.


Environment used in this runbook


  • Database: Oracle Database 19c (19.22) Enterprise Edition, container database PROD

  • PDB: SALESPDB, with the application schema APP and the runtime account APP_RUNTIME

  • DBA account: DBA_ADMIN, holding the DBA role

  • Licence: Oracle Database Vault is an extra-cost option for Enterprise Edition on premises and on IaaS. It is included in Autonomous Database.



How Database Vault Works

  • Realms are protection zones around schemas or objects. Inside a realm, system privileges such as SELECT ANY TABLE no longer work. Only accounts authorised in the realm can use their privileges there.

  • A mandatory realm goes further: even object privileges and the schema owner itself are blocked unless explicitly authorised.

  • Command rules control when and how a SQL command may run (for example DROP TABLE only on Sundays), using rule sets that evaluate conditions.

  • Separation of duties comes from two new roles: the Database Vault owner (DV_OWNER) defines realms and rules, and the account manager (DV_ACCTMGR) creates and manages users. SYS and the DBA role lose both abilities.



Step 1: Check the Current Status

Database Vault is installed with every Enterprise Edition 19c home, but it is not configured or enabled by default. Confirm the starting state in the CDB root.


SQL

sqlplus / as sysdba

SELECT parameter, value FROM v$option

WHERE parameter IN ('Oracle Database Vault','Oracle Label Security');

SELECT * FROM dba_dv_status;

Expected output

PARAMETER                      VALUE
------------------------------ ----------
Oracle Label Security          FALSE
Oracle Database Vault          FALSE

NAME                STATUS
------------------- --------------
DV_APP_PROTECTION   NOT CONFIGURED
DV_CONFIGURE_STATUS FALSE
DV_ENABLE_STATUS    FALSE

What to expect: Database Vault is FALSE in V$OPTION and both DV_CONFIGURE_STATUS and DV_ENABLE_STATUS are FALSE. In a container database, Database Vault must be configured and enabled in the CDB root first, then in each PDB that needs it.



Step 2: Create the Database Vault Administration Accounts

Create two common users in the CDB root: one for the Database Vault owner and one for the account manager. Also create backup accounts for both, because if the only DV owner forgets the password, nobody can change the realms.


SQL

-- CDB root, as SYS

CREATE USER c##dv_owner IDENTIFIED BY "Owner#Pwd2026" CONTAINER = ALL;

CREATE USER c##dv_owner_bk IDENTIFIED BY "OwnerBk#Pwd2026" CONTAINER = ALL;

CREATE USER c##dv_acctmgr IDENTIFIED BY "AcctMgr#Pwd2026" CONTAINER = ALL;

CREATE USER c##dv_acctmgr_bk IDENTIFIED BY "AcctBk#Pwd2026" CONTAINER = ALL;

GRANT CREATE SESSION, SET CONTAINER TO c##dv_owner, c##dv_owner_bk,

c##dv_acctmgr, c##dv_acctmgr_bk CONTAINER = ALL;

Expected output

User created.

User created.

User created.

User created.

Grant succeeded.

What this does: These accounts will receive DV_OWNER and DV_ACCTMGR in the next step. Hand the passwords to the security team, not the DBAs: the separation of duties only works if different people hold them.



Step 3: Configure and Enable Database Vault in the CDB Root

CONFIGURE_DV registers the accounts and grants them the Database Vault roles. ENABLE_DV, run as the DV owner, switches enforcement on. The change takes effect after a restart of the CDB.


SQL

-- As SYS in the CDB root

BEGIN

DVSYS.CONFIGURE_DV(

dvowner_uname => 'C##DV_OWNER',

dvacctmgr_uname => 'C##DV_ACCTMGR');

END;

/

@?/rdbms/admin/utlrp.sql

CONNECT c##dv_owner/"Owner#Pwd2026"

EXEC DBMS_MACADM.ENABLE_DV;

-- Grant the backup accounts while connected as the owner and the account manager

GRANT DV_OWNER TO c##dv_owner_bk CONTAINER = ALL;

CONNECT c##dv_acctmgr/"AcctMgr#Pwd2026"

GRANT DV_ACCTMGR TO c##dv_acctmgr_bk CONTAINER = ALL;

CONNECT / AS SYSDBA

SHUTDOWN IMMEDIATE

STARTUP

SELECT * FROM dba_dv_status;

Expected output

PL/SQL procedure successfully completed.

PL/SQL procedure successfully completed.

Grant succeeded.

Grant succeeded.

NAME                STATUS
------------------- --------------
DV_APP_PROTECTION   NOT CONFIGURED
DV_CONFIGURE_STATUS TRUE
DV_ENABLE_STATUS    TRUE

What to expect: After the restart both statuses are TRUE in the root. On RAC, restart all instances with srvctl stop database and srvctl start database. From now on, SYS can no longer create users (that needs DV_ACCTMGR) or grant Database Vault roles.



Step 4: Configure and Enable It in the PDB

Repeat the configuration in SALESPDB with the same common accounts, then close and open the PDB.


SQL

-- As SYS

ALTER SESSION SET CONTAINER = salespdb;

BEGIN

DVSYS.CONFIGURE_DV(

dvowner_uname => 'C##DV_OWNER',

dvacctmgr_uname => 'C##DV_ACCTMGR');

END;

/

CONNECT c##dv_owner/"Owner#Pwd2026"@salespdb

EXEC DBMS_MACADM.ENABLE_DV;

CONNECT / AS SYSDBA

ALTER PLUGGABLE DATABASE salespdb CLOSE IMMEDIATE;

ALTER PLUGGABLE DATABASE salespdb OPEN;

ALTER SESSION SET CONTAINER = salespdb;

SELECT * FROM dba_dv_status;

Expected output

PL/SQL procedure successfully completed.

PL/SQL procedure successfully completed.

Pluggable database altered.

Pluggable database altered.

NAME                STATUS
------------------- --------------
DV_APP_PROTECTION   NOT CONFIGURED
DV_CONFIGURE_STATUS TRUE
DV_ENABLE_STATUS    TRUE

What to expect: Database Vault is configured and enabled in SALESPDB. Nothing is protected yet: Database Vault only blocks access once realms and command rules exist. The application keeps running as before.



Step 5: Create the Realm in Simulation Mode

A realm in simulation mode logs what it would have blocked, without blocking anything. Run it for at least a week against real production traffic, including month-end jobs if possible, and read the log: every entry is either a process you must authorise or an access that should not be happening.


SQL

CONNECT c##dv_owner/"Owner#Pwd2026"@salespdb

BEGIN

DBMS_MACADM.CREATE_REALM(

realm_name => 'APP Data Realm',

description => 'Customer and payment data; no administrator access',

enabled => DBMS_MACUTL.G_SIMULATION,

audit_options => DBMS_MACUTL.G_REALM_AUDIT_FAIL,

realm_type => 1);

DBMS_MACADM.ADD_OBJECT_TO_REALM(

realm_name => 'APP Data Realm',

object_owner => 'APP',

object_name => '%',

object_type => '%');

END;

/

SELECT name, enabled, realm_type FROM dba_dv_realm WHERE name = 'APP Data Realm';

Expected output

PL/SQL procedure successfully completed.

NAME                 ENABLED REALM_TYPE
-------------------- ------- ----------
APP Data Realm       S       MANDATORY

What this does: The realm covers every object owned by APP (object_name and object_type '%'). ENABLED shows S for simulation. realm_type 1 makes it a mandatory realm, so even the APP schema owner and accounts holding object grants are blocked unless they are authorised in the realm. That is what you want for data that only controlled accounts should touch.



Step 6: Read the Simulation Log

After the simulation period, list who would have been blocked and from which program. Group the entries so that a busy log is readable.


SQL

SELECT username, machine, command, COUNT(*) AS hits,

TO_CHAR(MAX(timestamp),'YYYY-MM-DD HH24:MI') AS last_seen

FROM dba_dv_simulation_log

WHERE realm_name = 'APP Data Realm'

GROUP BY username, machine, command

ORDER BY hits DESC;

Expected output

USERNAME        MACHINE           COMMAND             HITS LAST_SEEN
--------------- ----------------- ------------ ----------- ----------------
APP_RUNTIME     app-prod-01       SELECT           2841106 2026-08-25 23:59
APP_RUNTIME     app-prod-01       UPDATE            412377 2026-08-25 23:59
APP_RUNTIME     app-prod-02       INSERT            220914 2026-08-25 23:58
APP             deploy-runner-01  ALTER TABLE           38 2026-08-23 03:12
DBA_ADMIN       dba-jumphost      SELECT                17 2026-08-24 10:44
SYSTEM          db-prod-01        SELECT                 6 2026-08-23 01:30

How to read it: APP_RUNTIME is the application and must be authorised. APP running ALTER TABLE from the deployment runner is the release process and must be authorised as the owner. DBA_ADMIN reading application tables from the jump host is exactly what the realm is meant to stop. SYSTEM at 01:30 is worth investigating: here it was a Data Pump job, which gets its own authorisation in Step 11.



Step 7: Authorise the Right Accounts and Enforce

Authorise the schema owner for deployments and the runtime account as a participant (it can use its privileges inside the realm, but cannot grant them). Then switch the realm from simulation to enforcement.


SQL

BEGIN

DBMS_MACADM.ADD_AUTH_TO_REALM(

realm_name => 'APP Data Realm',

grantee => 'APP',

auth_options => DBMS_MACUTL.G_REALM_AUTH_OWNER);

DBMS_MACADM.ADD_AUTH_TO_REALM(

realm_name => 'APP Data Realm',

grantee => 'APP_RUNTIME',

auth_options => DBMS_MACUTL.G_REALM_AUTH_PARTICIPANT);

DBMS_MACADM.UPDATE_REALM(

realm_name => 'APP Data Realm',

description => 'Customer and payment data; no administrator access',

enabled => DBMS_MACUTL.G_YES,

audit_options => DBMS_MACUTL.G_REALM_AUDIT_FAIL,

realm_type => 1);

END;

/

SELECT realm_name, grantee, auth_options FROM dba_dv_realm_auth WHERE realm_name = 'APP Data Realm';

SELECT name, enabled FROM dba_dv_realm WHERE name = 'APP Data Realm';

Expected output

PL/SQL procedure successfully completed.

REALM_NAME           GRANTEE         AUTH_OPTIONS
-------------------- --------------- ------------
APP Data Realm       APP             Owner
APP Data Realm       APP_RUNTIME     Participant

NAME                 ENABLED
-------------------- -------
APP Data Realm       Y

What to expect: Two authorisations, and ENABLED is now Y. From this moment the realm is enforced. Keep the simulation log query handy for the first days: anything you missed shows up as a real error for its user, so watch the application's error log closely during the first business day.



Step 8: Record Realm Violations with Unified Auditing

In 19c, Database Vault events are audited through unified audit policies. Create a policy that records every realm violation, so that each blocked attempt leaves evidence for the auditors.


SQL

-- As a user with AUDIT_ADMIN, in SALESPDB

CREATE AUDIT POLICY dv_app_realm_violations

ACTIONS COMPONENT = DV REALM VIOLATION ON "APP Data Realm";

AUDIT POLICY dv_app_realm_violations;

SELECT policy_name, enabled_option, entity_name

FROM audit_unified_enabled_policies

WHERE policy_name = 'DV_APP_REALM_VIOLATIONS';

Expected output

Audit policy created.

Audit succeeded.

POLICY_NAME               ENABLED_OPTION  ENTITY_NAME
------------------------- --------------- -----------
DV_APP_REALM_VIOLATIONS   BY USER         ALL USERS

What this does: The policy audits realm violations for all users. Successful access by authorised accounts is not audited by this policy, which keeps the audit trail small; add a second policy with REALM ACCESS if the auditors also want successful accesses.



Step 9: Prove It

Test the three cases the auditors care about: the DBA is blocked, the application works, and the attempt is on record.


SQL

-- As DBA_ADMIN, who holds the DBA role and SELECT ANY TABLE

CONNECT dba_admin@salespdb

SELECT COUNT(*) FROM app.customers;

-- As the application account

CONNECT app_runtime@salespdb

SELECT COUNT(*) FROM app.customers;

-- As the auditor: the violation is recorded

SELECT TO_CHAR(event_timestamp,'YYYY-MM-DD HH24:MI') AS event_time, dbusername,

action_name, object_schema, object_name, return_code

FROM unified_audit_trail

WHERE audit_type = 'Database Vault'

AND dv_object_name = 'APP Data Realm'

ORDER BY event_timestamp DESC

FETCH FIRST 1 ROWS ONLY;

Expected output

SELECT COUNT(*) FROM app.customers
                         *
ERROR at line 1:
ORA-01031: insufficient privileges

  COUNT(*)
----------
   4812094

EVENT_TIME       DBUSERNAME ACTION_NAME           OBJECT_SCHEMA OBJECT_NAME RETURN_CODE
---------------- ---------- --------------------- ------------- ----------- -----------
2026-08-26 10:12 DBA_ADMIN  Realm Violation Audit APP           CUSTOMERS          1031

What to expect: The DBA gets ORA-01031 even with SELECT ANY TABLE, the runtime account reads the table as before, and the audit trail shows the violation with the user, the object and the return code. Save this output: it is the evidence the auditors asked for.



Step 10: Add a Change-Window Command Rule

Realms stop unauthorised access. Command rules stop authorised accounts from doing the wrong thing at the wrong time. This rule set allows DROP TABLE and TRUNCATE TABLE on APP objects only on Sundays between 01:00 and 05:59, for everyone, including the schema owner.


SQL

CONNECT c##dv_owner/"Owner#Pwd2026"@salespdb

BEGIN

DBMS_MACADM.CREATE_RULE(

rule_name => 'Sunday change window',

rule_expr => 'TO_CHAR(SYSDATE,''DY'',''NLS_DATE_LANGUAGE=ENGLISH'') = ''SUN'' AND TO_NUMBER(TO_CHAR(SYSDATE,''HH24'')) BETWEEN 1 AND 5');

DBMS_MACADM.CREATE_RULE_SET(

rule_set_name => 'APP change window',

description => 'DDL on APP only during the Sunday window',

enabled => DBMS_MACUTL.G_YES,

eval_options => DBMS_MACUTL.G_RULESET_EVAL_ALL,

audit_options => DBMS_MACUTL.G_RULESET_AUDIT_FAIL,

fail_options => DBMS_MACUTL.G_RULESET_FAIL_SHOW,

fail_message => 'DDL on APP is allowed only in the Sunday change window',

fail_code => 20100,

handler_options => DBMS_MACUTL.G_RULESET_HANDLER_OFF,

handler => NULL);

DBMS_MACADM.ADD_RULE_TO_RULE_SET('APP change window', 'Sunday change window');

DBMS_MACADM.CREATE_COMMAND_RULE(

command => 'DROP TABLE', rule_set_name => 'APP change window',

object_owner => 'APP', object_name => '%', enabled => DBMS_MACUTL.G_YES);

DBMS_MACADM.CREATE_COMMAND_RULE(

command => 'TRUNCATE TABLE', rule_set_name => 'APP change window',

object_owner => 'APP', object_name => '%', enabled => DBMS_MACUTL.G_YES);

END;

/

-- Test on a weekday, as APP

CONNECT app@salespdb

TRUNCATE TABLE app.session_cache;

Expected output

PL/SQL procedure successfully completed.

TRUNCATE TABLE app.session_cache
                   *
ERROR at line 1:
ORA-47306: 20100: DDL on APP is allowed only in the Sunday change window

What this does: On a weekday the TRUNCATE fails with the custom message, so the person running it knows exactly why. The NLS_DATE_LANGUAGE argument makes the day-of-week check independent of the session language. In an emergency, the DV owner can disable the command rule for a few minutes with DBMS_MACADM.UPDATE_COMMAND_RULE, and that change is itself audited.



Step 11: Keep Operations Working

Database Vault blocks some routine DBA work until it is explicitly allowed. Grant these authorisations for the duration of the work, then revoke them.


SQL

-- Patching (datapatch) and some maintenance: grant before, revoke after

CONNECT c##dv_owner/"Owner#Pwd2026"

GRANT DV_PATCH_ADMIN TO SYS CONTAINER = ALL;

-- ... run datapatch ...

REVOKE DV_PATCH_ADMIN FROM SYS CONTAINER = ALL;

-- Data Pump exports of the protected schema by SYSTEM

CONNECT c##dv_owner/"Owner#Pwd2026"@salespdb

EXEC DBMS_MACADM.AUTHORIZE_DATAPUMP_USER('SYSTEM', 'APP');

-- Scheduler jobs that SYSTEM runs on behalf of APP

EXEC DBMS_MACADM.AUTHORIZE_SCHEDULER_USER('SYSTEM', 'APP');

SELECT grantee, schema, object, type FROM dba_dv_datapump_auth;

Expected output

Grant succeeded.

Revoke succeeded.

PL/SQL procedure successfully completed.

PL/SQL procedure successfully completed.

GRANTEE    SCHEMA     OBJECT     TYPE
---------- ---------- ---------- ----------
SYSTEM     APP        %          %

What to expect: SYSTEM can now export and import the APP schema with Data Pump (needed for refreshes and logical backups), and run scheduler jobs for it. RMAN backups are not affected by realms, because RMAN reads blocks, not rows. Review DBA_DV_DATAPUMP_AUTH every quarter and remove authorisations nobody needs any more with DBMS_MACADM.UNAUTHORIZE_DATAPUMP_USER.


Tip: Keep a short runbook for "Database Vault is blocking production" with the two people who hold DV owner credentials and their phone numbers. Most Database Vault incidents are a missing authorisation for a new job, fixed in one minute by the right person.


Across Clouds

  • Autonomous Database: Database Vault is included. Configure it with DBMS_CLOUD_MACADM.CONFIGURE_DATABASE_VAULT('dbv_owner','dbv_acctmgr') as ADMIN, enable it with DBMS_CLOUD_MACADM.ENABLE_DATABASE_VAULT, and restart the database. Realms and command rules then use the same DBMS_MACADM procedures as above.

  • Base Database and Exadata Database Service on OCI, and Oracle Database@Azure, @Google Cloud and @AWS: these run standard Oracle Database, so Steps 1 to 11 apply exactly. Check the licence model of the service: Database Vault is included in the Enterprise Edition Extreme Performance and Exadata licence-included editions.

  • Amazon RDS for Oracle: does not support Database Vault. A workload that needs this control runs self-managed on EC2, or on an OCI service, Oracle Database@AWS included. On RDS, the closest controls are Virtual Private Database and fine-grained auditing.



Summary

Database Vault turns "the DBAs promise not to look" into a control the database enforces. Configure and enable it in the CDB root and then the PDB with separate owner and account manager accounts held by the security team. Create a mandatory realm around the application schema in simulation mode, read the simulation log, authorise the owner and the runtime account, then enforce it. Audit violations with a unified audit policy, prove the result with a DBA, an application and an auditor test, add command rules for change windows, and authorise patching, Data Pump and scheduler work explicitly.

Recent Posts

See All

Comments


bottom of page