-- 적용 전
EMPLOYEE_ID FIRST_NAME LAST_NAME SALARY EMAIL PHONE_NUMBER
----------- ---------- --------- ------ --------- ------------
205 Shelly Higgins 12008 SHIGGINS 515.123.8080
206 William Gletz 8300 WGIETZ 515.123.8181
-- 적용 후
EMPLOYEE_ID FIRST_NAME LAST_NAME SALARY EMAIL PHONE_NUMBER
----------- ---------- --------- ------ --------- ------------
205 Shelly H****** 0 ,T"/& ***.***.***
206 William G**** 0 lii4rw>N ***.***.***
CREATE TABLE HR.RDTEST1 AS SELECT * FROM HR.EMPLOYEES;
-- CLERK 롤
CREATE ROLE CLERK;
GRANT CLERK TO SCOTT;
GRANT SELECT ON HR.RDTEST1 TO SCOTT;
BEGIN DBMS_REDACT.ADD_POLICY(
OBJECT_SCHEMA => 'HR'
OBJECT_NAME => 'RDTEST1'
COLUMN_NAME => 'SALARY'
POLICY_NAME => 'REDACT_RDTEST1'
POLICY_DESCRIPTION => 'REDACT_RDTEST1 PII'
FUNCTION_TYPE => DBMS_REDACT.FULL,
EXPRESSION => 'SYS_CONTEXT(''SYS_SESSION_ROLES'',''CLERK'' ) = ''FALSE''');
END;
/
SELECT EMPLOYEE_ID, FIRST_NAME, LAST_NAME, SALARY, EMAIL, PHONE_NUMBER
FROM HR.RDTEST1
WHERE EMPLOYEE_ID IN ( 205, 206 );
-- SALARY 적용
EMPLOYEE_ID FIRST_NAME LAST_NAME SALARY EMAIL PHONE_NUMBER
----------- ---------- --------- ------ --------- ------------
205 Shelly Higgins 0 SHIGGINS 515.123.8080
206 William Gletz 0 WGIETZ 515.123.8181
BEGIN DBMS_REDACT.ALTER_POLICY(
OBJECT_SCHEMA => 'HR',
OBJECT_NAME => 'RDTEST1',
COLUMN_NAME => 'LAST_NAME',
POLICY_NAME => 'REDACT_RDTEST1',
POLICY_DESCRIPTION => 'REDACT_RDTEST1 PII',
ACTION => DBMS_REDACT.ADD_COLUMN, -- 추가
FUNCTION_TYPE => DBMS_REDACT.PARTIAL,
FUNCTION_PARAMETERS => 'VVVVVVVVVVVVVVVVVV,VVVVVVVVVVVVVVVVVV,*,2,25',
EXPRESSION => 'SYS_CONTEXT(''SYS_SESSION_ROLES'',''CLERK'' ) = ''FALSE''');
END;
/
-- LAST_NAME 적용
EMPLOYEE_ID FIRST_NAME LAST_NAME SALARY EMAIL PHONE_NUMBER
----------- ---------- --------- ------ --------- ------------
205 Shelly H****** 0 SHIGGINS 515.123.8080
206 William G**** 0 WGIETZ 515.123.8181
BEGIN DBMS_REDACT.ALTER_POLICY(
OBJECT_SCHEMA => 'HR',
OBJECT_NAME => 'RDTEST1',
COLUMN_NAME => 'EMAIL',
POLICY_NAME => 'REDACT_RDTEST1',
POLICY_DESCRIPTION => 'REDACT_RDTEST1 PII',
ACTION => DBMS_REDACT.ADD_COLUMN,
FUNCTION_TYPE => DBMS_REDACT.PARTIAL,
FUNCTION_PARAMETERS => DBMS_REDACT.RANDOM, --
EXPRESSION => 'SYS_CONTEXT(''SYS_SESSION_ROLES'',''CLERK'' ) = ''FALSE''');
END;
/
-- EMAIL 적용
EMPLOYEE_ID FIRST_NAME LAST_NAME SALARY EMAIL PHONE_NUMBER
----------- ---------- --------- ------ --------- ------------
205 Shelly H****** 0 30fjm2os 515.123.8080
206 William G**** 0 aafaf3-dk 515.123.8181
BEGIN DBMS_REDACT.ALTER_POLICY(
OBJECT_SCHEMA => 'HR',
OBJECT_NAME => 'RDTEST1',
COLUMN_NAME => 'PHONE_NUMBER',
POLICY_NAME => 'REDACT_RDTEST1',
POLICY_DESCRIPTION => 'REDACT_RDTEST1 PII',
ACTION => DBMS_REDACT.ADD_COLUMN,
FUNCTION_TYPE => DBMS_REDACT.REGEXP,
EXPRESSION => 'SYS_CONTEXT(''SYS_SESSION_ROLES'',''CLERK'' ) = ''FALSE''');
REGEXP_PATTERN => ('(\d\d\d).(\d\d\d).(\d\d\d\d)',
REGEXP_REPLACE_STRING => '***.***.****',
REGEXP_POSITION => 1,
REGEXP_OCCURRENCE => 0, REGEXP_MATCH_PARAMETER => 'i' );
END;
/
-- PHONE_NUMBER 적용
EMPLOYEE_ID FIRST_NAME LAST_NAME SALARY EMAIL PHONE_NUMBER
----------- ---------- --------- ------ --------- ------------
205 Shelly H****** 0 30fjm2os ***.***.****
206 William G**** 0 aafaf3-dk ***.***.****
-- Data Redaction 적용된 테이블 : HR.RDTEST1
CREATE OR REPLACE VIEW HR.V1
AS
SELECT EMPLOYEE_ID, FIRST_NAME, LAST_NAME,
SALARY, EMAIL, PHONE_NUMBER
FROM HR.RDTEST1;
BEGIN DBMS_REDACT.ALTER_POLICY(
OBJECT_SCHEMA => 'HR',
OBJECT_NAME => 'V1',
COLUMN_NAME => 'PHONE_NUMBER',
POLICY_NAME => 'NO_RD_PHONE_NUM',
FUNCTION_TYPE => DBMS_REDACT.NONE,
EXPRESSION => '1=1');
END;
/
-- HR 유저로 다음 쿼리를 수행해서 Data Redaction이 취소된 것을 확인한다.
EMPLOYEE_ID FIRST_NAME LAST_NAME SALARY EMAIL PHONE_NUMBER
----------- ---------- --------- ------ --------- ------------
205 Shelly H****** 0 30fjm2os 515.123.8080
206 William G**** 0 aafaf3-dk 515.123.8181
- 강좌 URL : http://www.gurubee.net/lecture/4267
- 구루비 강좌는 개인의 학습용으로만 사용 할 수 있으며, 다른 웹 페이지에 게재할 경우에는 출처를 꼭 밝혀 주시면 고맙겠습니다.~^^
- 구루비 강좌는 서비스 제공을 위한 목적이나, 학원 홍보, 수익을 얻기 위한 용도로 사용 할 수 없습니다.