Oracle Data Redaction hides or obfuscates column values at query-time without changing the data on disk.
Data masking prevents developers, analysts, and attackers from seeing real customer emails, credit-card numbers, or salaries in lower environments while letting applications continue to run normally.
The DBMS_REDACT package attaches policies to tables or views. When a query matches the policy predicate, Oracle rewrites the result set, replacing sensitive column values with full, partial, or random masks.
Start with PII in Customers.email
, Customers.name
, payment data in Orders.total_amount
, and any token or API key columns. Prioritize by regulatory requirements (GDPR, PCI-DSS, HIPAA).
GRANT EXEMPT REDACTION POLICY TO admin_user;
BEGIN
DBMS_REDACT.ADD_POLICY(
object_schema => 'ECOM',
object_name => 'CUSTOMERS',
column_name => 'EMAIL',
policy_name => 'mask_email',
function_type => DBMS_REDACT.PARTIAL,
function_parameters => '0,2,NULL,@@example.com',
expression => 'SYS_CONTEXT(''USERENV'',''SESSION_USER'')<>''ADMIN_USER'''
);
END;
/
This keeps the first two characters and replaces the domain for every non-admin session.
Yes. Call ADD_POLICY
again for each column or pass a comma-separated list to column_name
.
-- Session as DEV_USER
SELECT id, email FROM ecom.customers WHERE id = 42;
-- Returns: j@****@@example.com
Connect as ADMIN_USER
and rerun the query to see the original value, confirming the policy works.
Disable temporarily with DBMS_REDACT.ALTER_POLICY(..., action => DBMS_REDACT.DISABLE);
or remove it permanently using DBMS_REDACT.DROP_POLICY
.
Yes. Pass a comma-separated list of columns or call ADD_POLICY
separately for each column you want to protect.
Redaction adds minimal overhead because masking happens in memory after the data is fetched. Benchmarks show single-digit millisecond impact for typical OLTP queries.
No. Oracle rewrites the result set at runtime. The underlying data stays unchanged, ensuring reports and backups remain accurate.