My Oracle Support Banner

Is It Possible To use regular expression redaction policy to NCHAR, NVARCHAR2 DATATYPE on Oracle Database 12c Release1 (12.1) ? (Doc ID 2218504.1)

Last updated on FEBRUARY 28, 2019

Applies to:

Oracle Database - Enterprise Edition - Version 12.1.0.1 to 12.1.0.2 [Release 12.1]
Oracle Database Cloud Schema Service - Version N/A and later
Oracle Database Exadata Cloud Machine - Version N/A and later
Oracle Cloud Infrastructure - Database Service - Version N/A and later
Oracle Database Cloud Exadata Service - Version N/A and later
Information in this document applies to any platform.

Goal

NOTE: In the images and/or the document content below, the user information and data used represents fictitious data from the Oracle sample schema(s) or Public Documentation delivered with an Oracle.

 

Is it possible to use regular expression redaction policy to NCHAR, NVARCHAR2 DATATYPE on Oracle Database 12c Release1 (12.1) ?

When executing sample script, It seems that full redaction is performed instead of regular expression redaction.

SQL> connect USER1/XXXXX
Connected.
SQL> drop table test;

Table dropped.

SQL> create table test (c1 nchar(5));

Table created.

SQL> insert into test values ('12345');

1 row created.

SQL> commit;

Commit complete.

SQL>
SQL> connect / as sysdba
Connected.
SQL>
SQL> BEGIN
2 DBMS_REDACT.ADD_POLICY(OBJECT_SCHEMA => 'USER1',
3 object_name => 'TEST',
4 policy_name =>'SYSTEM_REDACT',
5 COLUMN_NAME => 'C1', FUNCTION_TYPE => DBMS_REDACT.REGEXP,
6 FUNCTION_PARAMETERS => NULL,
7 expression => '1=1',
8 REGEXP_PATTERN => '(\d\d\d)(\d\d)',
9 REGEXP_REPLACE_STRING => '\2\1',
10 REGEXP_POSITION => 1);
11 END;
12 /

PL/SQL procedure successfully completed.

SQL>
SQL>
SQL> Rem In the above regexp redaction policy, we are replacing the pattern
SQL> Rem '(\d\d\d)(\d\d)' with '\2\1'. An input string '12345' should be replaced
SQL> Rem by '45123'.
SQL>
SQL> connect USER1/XXXXX
Connected.
SQL> select c1 from test;

C1
--------------------------------------------------------------------------------

* Null data means that full redaction is performed.

Solution

To view full details, sign in with your My Oracle Support account.

Don't have a My Oracle Support account? Click to get started!


In this Document
Goal
Solution
References

My Oracle Support provides customers with access to over a million knowledge articles and a vibrant support community of peers and Oracle experts.