SQL> select ename,sal from emp;
ENAME SAL
---------- ----------
SMITH 800
ALLEN 1600
WARD 1250
JONES 2975
MARTIN 1250
BLAKE 2850
CLARK 2450
SCOTT 3000
KING 5000
TURNER 1500
ADAMS 1100
ENAME SAL
---------- ----------
JAMES 950
FORD 3000
MILLER 1300
已选择14行。
Then start to do data mask:
After job running.
Seee the result.
SQL> /
ENAME SAL
---------- ----------
SMITH 7707
ALLEN 6301
WARD 7109
JONES 6900
MARTIN 7109
TURNER 7604
JAMES 6302
BLAKE 7410
CLARK 6608
KING 6205
SCOTT 7403
ENAME SAL
---------- ----------
ADAMS 6211
FORD 7403
MILLER 6206
this help us hide the confidential data when clone or copy database to test or development.
Actually,the EM help us do the following things:
-- Target database: orcl.oracle.com
-- Script generated at: 05-JAN-2011 11:34
COMMIT
ALTER SESSION ENABLE PARALLEL DML
DROP TABLE "MGMT_DM_TT_7" PURGE
declare
adj number:=0;
num number:=0;
begin
select length(count(*)) into adj from (select distinct "SAL" from "SCOTT"."EMP");
num := adj;
adj := greatest(adj - 2, 0);
execute immediate 'create table MGMT_DM_TT_7
(orig_val null, new_val null) NOLOGGING PARALLEL as
select CAST(null AS NUMBER(7, 2)) orig_val, CAST(null AS NUMBER(7, 2)) new_val from dual union all
select s.orig_val,
case
when s.subset = 1 then
CAST(
lpad(6000 + mod(lpad(trunc(dbms_random.value(0, substr(2000, 1, 2 - least(2, greatest('||adj||' - 0, 0))))), 2 - least(2, greatest('||adj||' - 0, 0)), 0)
|| lpad(nvl(substr(s.new_num, 1, 2 + least(2, greatest('||adj||' - 0, 0))),0), 2 + least(2, greatest('||adj||' - 0, 0)), 0), 2000), 4, 0)
AS NUMBER(7, 2))
end new_val
from (select rownum rn, orig_val, subset, rid, lpad(rownum - 1, '||num||', 0) new_num
from (select "SAL" orig_val, min(rowid) rid, min(
case
when 1=1 then 1
end
) subset
from "SCOTT"."EMP" group by "SAL")) s
where 1=1 and s.orig_val is not null
';
DBMS_STATS.GATHER_TABLE_STATS(NULL, '"MGMT_DM_TT_7"', estimate_percent=>DBMS_STATS.AUTO_SAMPLE_SIZE, degree=>DBMS_STATS.DEFAULT_DEGREE);
end;
DECLARE
CURSOR fk_sql IS select refr.owner, refr.table_name, refr.constraint_name
from dba_constraints refd, dba_constraints refr
where refd.owner = 'SCOTT' and
refd.table_name = 'EMP' and
refr.constraint_type = 'R' and
refr.r_owner = refd.owner and
refr.r_constraint_name = refd.constraint_name;
BEGIN
FOR fk IN fk_sql
LOOP
EXECUTE IMMEDIATE 'ALTER TABLE "' || fk.owner || '"."' ||
fk.table_name || '" DROP CONSTRAINT "' || fk.constraint_name || '"';
END LOOP;
END;
DECLARE
CURSOR c_sql IS select owner, table_name, constraint_name,
constraint_type, generated, index_name from dba_constraints
where owner = 'SCOTT' and
table_name = 'EMP' and
constraint_type <> 'R';
BEGIN
FOR c IN c_sql
LOOP
EXECUTE IMMEDIATE 'ALTER TABLE "' || c.owner || '"."' ||
c.table_name || '" DROP CONSTRAINT "' || c.constraint_name || '"';
END LOOP;
END;
DROP INDEX "SCOTT"."PK_EMP"
ALTER TABLE "SCOTT"."EMP" RENAME TO "EMP$DMASK"
CREATE TABLE "SCOTT"."EMP" TABLESPACE "USERS" PCTFREE 10 INITRANS 1 MAXTRANS 255 STORAGE ( INITIAL 64K BUFFER_POOL DEFAULT) NOLOGGING PARALLEL AS SELECT s."EMPNO", s."ENAME", s."JOB", s."MGR", s."HIREDATE", c0m7.NEW_VAL "SAL", s."COMM", s."DEPTNO" FROM "SCOTT"."EMP$DMASK" s , MGMT_DM_TT_7 c0m7 WHERE sys_op_map_nonnull(s."SAL") = sys_op_map_nonnull(c0m7.ORIG_VAL)
ALTER TABLE "SCOTT"."EMP" LOGGING NOPARALLEL
DROP TABLE "SCOTT"."EMP$DMASK" PURGE
CREATE UNIQUE INDEX "SCOTT"."PK_EMP" ON "SCOTT"."EMP" ("EMPNO") TABLESPACE "USERS" PCTFREE 10 INITRANS 2 MAXTRANS 255 STORAGE ( INITIAL 64K BUFFER_POOL DEFAULT) LOGGING
ALTER TABLE "SCOTT"."EMP" ADD (CONSTRAINT "PK_EMP" PRIMARY KEY ("EMPNO") )
ALTER TABLE "SCOTT"."EMP" ADD (CONSTRAINT "FK_DEPTNO" FOREIGN KEY ("DEPTNO") REFERENCES "SCOTT"."DEPT" ("DEPTNO") )
ALTER MATERIALIZED VIEW "SCOTT"."MV1" COMPILE
BEGIN DBMS_STATS.GATHER_TABLE_STATS('"SCOTT"', '"EMP"', estimate_percent=>DBMS_STATS.AUTO_SAMPLE_SIZE, degree=>DBMS_STATS.DEFAULT_DEGREE, cascade=>TRUE); END;
分享到:
相关推荐
Creating Value with Big Data Analytics Making Smarter Marketing Decisions
on the science of data assimilation and incorporate developments during the last 5 years. It is designed to update the science of data assimilation since the NATO (North Atlantic Treaty Organization) ...
Data Analysis And Decision Making, 4ed - 2011.pdf
If you’re a data scientist who struggles to navigate the murky space between data and insight, this book will help you think about and reshape data for visual data exploration. It’s ideal for ...
Use mathematical and logical expressions to calculate sum, average, maximum, and to sort, arrange, and extract data making it easier for you to analyze, share, and manage business information more ...
Making Sense of Data A Practical Guide to Exploratory Data Analysis and Data Mining.pdf
Visualization is a vital tool for understanding and sharing insights around data. The right visualization can help express a core idea or open a space to examination; it can get the world talking ...
The module will introduce students to a range of approaches ... Such understanding of data analytics will be framed within the context of business decision making and the use of data to enhance the qua
Creating Value with Big Data Analytics provides a nuanced view of big data development, arguing that big data in itself is not a revolution but an evolution of the increasing availability of data that...
data mining on healtchare
Creating Value with Big Data Analytics Making Smart Marketing Decisions
Making Decisions About...and Planning Program Flow Object Oriented Programming with Objective-C Learning Objective-C and Xcode Objective-C Classes, Objects, and Methods Diving into Objective-C More ...
Making iOS and Android web apps Taking your game offline Using Web Workers Persistent Game Data Drawing with Canvas Capturing player input Creating 3D graphics with WebGL Textures and lighting Sound ...
This book is about using graphical methods to understand complex data by highlighting important relationships and trends, reducing the data to simpler forms, and making it possible to take in a lot ...
Decision Making and Performance Evaluation Using Data Envelopment Analysis 数据包络分析:决策与绩效评估
It uses implementations that allow students to explore models and data for the sake of discovery, understanding, and decision making. Business analytics is about using data and models to solve ...
Data Abstract uses a multi-tier approach to data access, making data access easy, fast and secure for the modern online world. On the server tier, you have full control over how data is accessed and ...
Jobs in data science are projected to outpace the number of people with data science skills-making those with the knowledge to fill a data science position a hot commodity in the coming years....
Data analytics has become core to business and decision making. The rapid increase in data volume, velocity and variety, known as big data, offers both opportunities and challenges. While open source...