Table of Contents

Search

  1. Abstract
  2. Supported Versions
  3. Dynamic Data Masking Default Masking Functionality

Dynamic Data Masking Default Masking Functionality

Dynamic Data Masking Default Masking Functionality

General Use Case #7: SQL statement that contains a subquery containing GROUP BY, HAVING, and ORDER BY clauses

General Use Case #7: SQL statement that contains a subquery containing GROUP BY, HAVING, and ORDER BY clauses

Use case #7 provides an example of a SQL statement that contains a subquery containing GROUP BY, HAVING, and ORDER BY clauses.
Example statement:
select FIRST_NAME,LAST_NAME,DEPARTMENT_ID from (SELECT FIRST_NAME,LAST_NAME||'.' LAST_NAME, DEPARTMENT_ID FROM EMPLOYEES WHERE LAST_NAME LIKE '%S%' OR FIRST_NAME LIKE '%JOHN%' GROUP BY FIRST_NAME,LAST_NAME,DEPARTMENT_ID HAVING COUNT(DEPARTMENT_ID) >= 1 AND LAST_NAME != 'Brown' ORDER BY FIRST_NAME,LAST_NAME,DEPARTMENT_ID) A GROUP BY first_name,last_name,DEPARTMENT_ID Having COUNT(DEPARTMENT_ID) >= 1 AND LAST_NAME != 'Brown' ORDER BY FIRST_NAME,LAST_NAME,DEPARTMENT_ID
The following table describes the example masking scenarios:
Keep Original Number of Rows
Old Masking Statement Modification
New Masking Statement Modification
Masking Action Functionality
N
select substr("FIRST_NAME",1,2) "FIRST_NAME" , substr("LAST_NAME",1,2)||'zzzz' "LAST_NAME" , DEPARTMENT_ID from ( SELECT substr("FIRST_NAME",1,2) "FIRST_NAME" ,substr("LAST_NAME",1,2)||'zzzz' || '.' LAST_NAME , DEPARTMENT_ID FROM EMPLOYEES WHERE LAST_NAME LIKE '%S%' OR FIRST_NAME LIKE '%JOHN%' GROUP BY substr("FIRST_NAME",1,2) ,substr("LAST_NAME",1,2)||'zzzz' , DEPARTMENT_ID HAVING COUNT ( DEPARTMENT_ID ) >= 1 AND substr("LAST_NAME",1,2)||'zzzz' != 'Brown' ORDER BY substr("FIRST_NAME",1,2) ,substr("LAST_NAME",1,2)||'zzzz' , DEPARTMENT_ID ) A GROUP BY substr("FIRST_NAME",1,2) ,substr("LAST_NAME",1,2)||'zzzz' , DEPARTMENT_ID HAVING COUNT ( DEPARTMENT_ID ) >= 1 AND substr("LAST_NAME",1,2)||'zzzz' != 'Brown' ORDER BY substr("FIRST_NAME",1,2) , substr("LAST_NAME",1,2)||'zzzz' , DEPARTMENT_ID
select substr(FIRST_NAME ,1,2) FIRST_NAME , LAST_NAME LAST_NAME , DEPARTMENT_ID from ( SELECT FIRST_NAME , substr(LAST_NAME ,1,2)||'zzzz' || '.' LAST_NAME , DEPARTMENT_ID FROM EMPLOYEES WHERE LAST_NAME LIKE '%S%' OR FIRST_NAME LIKE '%JOHN%' GROUP BY FIRST_NAME , LAST_NAME , DEPARTMENT_ID HAVING COUNT ( DEPARTMENT_ID )>= 1 AND LAST_NAME != 'Brown' ORDER BY FIRST_NAME , LAST_NAME , DEPARTMENT_ID ) A GROUP BY substr(first_name ,1,2) , last_name , DEPARTMENT_ID HAVING COUNT ( DEPARTMENT_ID ) >= 1 AND LAST_NAME != 'Brown' ORDER BY substr(FIRST_NAME ,1,2) , LAST_NAME , DEPARTMENT_ID
The old masking functionality resulted in incorrect masking, because columns are masked twice, in both the outer and inner queries.
Inner Query (for all the columns):
  • Group By - Y
  • Having - Y
  • Order By – Y
Outer Query (only for columns masked in the outer query):
  • Group By - Y
  • Having - Y
  • Order By – Y
New masking functionality:
If candidate columns are not masked in the inner query, then they are masked in the outer query, as per the following:
Inner Query (for all the columns):
  • Group By - N
  • Having - N
  • Order By – N
Outer Query (only for columns masked in the outer query):
  • Group By - Y
  • Having - Y
  • Order By – Y
Y
select substr("FIRST_NAME",1,2) "FIRST_NAME" , substr("LAST_NAME",1,2)||'zzzz' "LAST_NAME" , DEPARTMENT_ID from ( SELECT substr("FIRST_NAME",1,2) "FIRST_NAME" ,substr("LAST_NAME",1,2)||'zzzz' || '.' LAST_NAME , DEPARTMENT_ID FROM EMPLOYEES WHERE LAST_NAME LIKE '%S%' OR FIRST_NAME LIKE '%JOHN%' GROUP BY FIRST_NAME , LAST_NAME , DEPARTMENT_ID HAVING COUNT ( DEPARTMENT_ID ) >= 1 AND LAST_NAME != 'Brown' ORDER BY FIRST_NAME , LAST_NAME , DEPARTMENT_ID ) A GROUP BY first_name , last_name , DEPARTMENT_ID HAVING COUNT (DEPARTMENT_ID ) >= 1 AND LAST_NAME != 'Brown' ORDER BY FIRST_NAME , LAST_NAME , DEPARTMENT_ID
select substr(FIRST_NAME ,1,2) FIRST_NAME , LAST_NAME LAST_NAME , DEPARTMENT_ID from ( SELECT FIRST_NAME , substr(LAST_NAME ,1,2)||'zzzz' || '.' LAST_NAME , DEPARTMENT_ID FROM EMPLOYEES WHERE LAST_NAME LIKE '%S%' OR FIRST_NAME LIKE '%JOHN%' GROUP BY FIRST_NAME , LAST_NAME , DEPARTMENT_ID HAVING COUNT ( DEPARTMENT_ID ) >= 1 AND LAST_NAME != 'Brown' ORDER BY FIRST_NAME , LAST_NAME , DEPARTMENT_ID ) A GROUP BY first_name , last_name , DEPARTMENT_ID HAVING COUNT ( DEPARTMENT_ID )>= 1 AND LAST_NAME != 'Brown' ORDER BY FIRST_NAME ,LAST_NAME , DEPARTMENT_ID
The old masking functionality resulted in incorrect masking, because columns are masked twice, in both the outer and inner queries.
Inner Query (for all the columns):
  • Group By - N
  • Having - N
  • Order By – N
Outer Query (only for columns masked in the outer query):
  • Group By - N
  • Having - N
  • Order By – N
New masking functionality:
If candidate columns are not masked in the inner query, then they are masked in the outer query, as per the following:
Inner Query (for all the columns):
  • Group By - N
  • Having - N
  • Order By – N
Outer Query (only for columns masked in the outer query):
  • Group By - N
  • Having - N
  • Order By – N

0 COMMENTS

We’d like to hear from you!