Using DataPump Extract Schema DDL Scripts

[oracle@ggos dmp]$ expdp zwc/zwc directory=dir_dmp dumpfile=zwc.dmp logfile=zwc.expdp.log content=metadata_only

Export: Release 11.2.0.4.0 - Production on Wed Sep 25 18:04:58 2013

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
FLASHBACK automatically enabled to preserve database integrity.
Starting "ZWC"."SYS_EXPORT_SCHEMA_01":  zwc/******** directory=dir_dmp dumpfile=zwc.dmp logfile=zwc.expdp.log content=metadata_only 
Processing object type SCHEMA_EXPORT/USER
Processing object type SCHEMA_EXPORT/SYSTEM_GRANT
Processing object type SCHEMA_EXPORT/ROLE_GRANT
Processing object type SCHEMA_EXPORT/DEFAULT_ROLE
Processing object type SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA
Processing object type SCHEMA_EXPORT/TABLE/TABLE
Processing object type SCHEMA_EXPORT/TABLE/COMMENT
Processing object type SCHEMA_EXPORT/TABLE/INDEX/INDEX
Processing object type SCHEMA_EXPORT/TABLE/CONSTRAINT/CONSTRAINT
Processing object type SCHEMA_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
Processing object type SCHEMA_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
Master table "ZWC"."SYS_EXPORT_SCHEMA_01" successfully loaded/unloaded
******************************************************************************
Dump file set for ZWC.SYS_EXPORT_SCHEMA_01 is:
  /home/oracle/dmp/zwc.dmp
Job "ZWC"."SYS_EXPORT_SCHEMA_01" successfully completed at Wed Sep 25 18:05:27 2013 elapsed 0 00:00:26


[oracle@ggos dmp]$ impdp zwc/zwc directory=dir_dmp dumpfile=zwc.dmp  logfile=zwc.impdp.log sqlfile=zwc.sql

Import: Release 11.2.0.4.0 - Production on Wed Sep 25 18:07:46 2013

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Master table "ZWC"."SYS_SQL_FILE_FULL_01" successfully loaded/unloaded
Starting "ZWC"."SYS_SQL_FILE_FULL_01":  zwc/******** directory=dir_dmp dumpfile=zwc.dmp logfile=zwc.impdp.log sqlfile=zwc.sql 
Processing object type SCHEMA_EXPORT/USER
Processing object type SCHEMA_EXPORT/SYSTEM_GRANT
Processing object type SCHEMA_EXPORT/ROLE_GRANT
Processing object type SCHEMA_EXPORT/DEFAULT_ROLE
Processing object type SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA
Processing object type SCHEMA_EXPORT/TABLE/TABLE
Processing object type SCHEMA_EXPORT/TABLE/CONSTRAINT/CONSTRAINT
Processing object type SCHEMA_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
Processing object type SCHEMA_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
Job "ZWC"."SYS_SQL_FILE_FULL_01" successfully completed at Wed Sep 25 18:07:51 2013 elapsed 0 00:00:03

[oracle@ggos dmp]$ cat zwc.sql 
-- CONNECT ZWC
ALTER SESSION SET EVENTS '10150 TRACE NAME CONTEXT FOREVER, LEVEL 1';
ALTER SESSION SET EVENTS '10904 TRACE NAME CONTEXT FOREVER, LEVEL 1';
ALTER SESSION SET EVENTS '25475 TRACE NAME CONTEXT FOREVER, LEVEL 1';
ALTER SESSION SET EVENTS '10407 TRACE NAME CONTEXT FOREVER, LEVEL 1';
ALTER SESSION SET EVENTS '10851 TRACE NAME CONTEXT FOREVER, LEVEL 1';
ALTER SESSION SET EVENTS '22830 TRACE NAME CONTEXT FOREVER, LEVEL 192 ';
-- new object type path: SCHEMA_EXPORT/USER
-- CONNECT SYSTEM
 CREATE USER "ZWC" IDENTIFIED BY VALUES 'S:DBE2DAA919F39CB428BCF983152D62121C531B8765E5A939FEE934D88291;D9DB253E6372625E'
      DEFAULT TABLESPACE "USERS"
      TEMPORARY TABLESPACE "TEMP";
-- new object type path: SCHEMA_EXPORT/SYSTEM_GRANT
GRANT UNLIMITED TABLESPACE TO "ZWC";
-- new object type path: SCHEMA_EXPORT/ROLE_GRANT
 GRANT "DBA" TO "ZWC";
 GRANT "EXP_FULL_DATABASE" TO "ZWC";
 GRANT "IMP_FULL_DATABASE" TO "ZWC";
-- new object type path: SCHEMA_EXPORT/DEFAULT_ROLE
 ALTER USER "ZWC" DEFAULT ROLE ALL;
-- new object type path: SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA
-- CONNECT ZWC

BEGIN 
sys.dbms_logrep_imp.instantiate_schema(schema_name=>SYS_CONTEXT('USERENV','CURRENT_SCHEMA'), export_db_name=>'ORAPROD', inst_scn=>'1105079');
COMMIT; 
END; 
/ 
-- new object type path: SCHEMA_EXPORT/TABLE/TABLE
CREATE TABLE "ZWC"."GGTEST" 
   (    "COL1" NUMBER, 
        "COL2" VARCHAR2(50 BYTE)
   ) SEGMENT CREATION IMMEDIATE 
  PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 
 NOCOMPRESS LOGGING
  STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
  PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1
  BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
  TABLESPACE "USERS" ;
-- new object type path: SCHEMA_EXPORT/TABLE/CONSTRAINT/CONSTRAINT
ALTER TABLE "ZWC"."GGTEST" ADD PRIMARY KEY ("COL1")
  USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 
  STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
  PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1
  BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
  TABLESPACE "USERS"  ENABLE;
-- new object type path: SCHEMA_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
DECLARE I_N VARCHAR2(60); 
  I_O VARCHAR2(60); 
  NV VARCHAR2(1); 
  c DBMS_METADATA.T_VAR_COLL; 
  df varchar2(21) := 'YYYY-MM-DD:HH24:MI:SS'; 
 stmt varchar2(300) := ' INSERT INTO "SYS"."IMPDP_STATS" (type,version,flags,c1,c2,c3,c5,n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12,d1,cl1) VALUES (''I'',6,:1,:2,:3,:4,:5,:6,:7,:8,:9,:10,:11,:12,:13,NULL,:14,:15,NULL,:16,:17)';
BEGIN
  DELETE FROM "SYS"."IMPDP_STATS"; 
  c(1) := 'COL1';

  DBMS_METADATA.GET_STAT_INDNAME('ZWC','GGTEST',c,1,i_o,i_n); 
  EXECUTE IMMEDIATE stmt USING 2,I_N,NV,NV,I_O,0,0,0,0,0,0,0,0,NV,NV,TO_DATE('2013-09-04 22:00:14',df),NV;

  DBMS_STATS.IMPORT_INDEX_STATS('"' || i_o || '"','"' || i_n || '"',NULL,'"IMPDP_STATS"',NULL,'"SYS"'); 
  DELETE FROM "SYS"."IMPDP_STATS"; 
END; 
/
-- new object type path: SCHEMA_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
DECLARE 
  c varchar2(60); 
  nv varchar2(1); 
  df varchar2(21) := 'YYYY-MM-DD:HH24:MI:SS'; 
  s varchar2(60) := 'ZWC'; 
  t varchar2(60) := 'GGTEST'; 
  p varchar2(1); 
  sp varchar2(1); 
  stmt varchar2(300) := 'INSERT INTO "SYS"."IMPDP_STATS" (type,version,c1,c2,c3,c4,c5,n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,d1,r1,r2,ch1,flags,cl1) VALUES (:1,6,:2,:3,:4,:5,:6,:7,:8,:9,:10,:11,:12,:13,:14,:15,:16,:17,:18,:19,:20,:21,:22,:23)';
BEGIN
  DELETE FROM "SYS"."IMPDP_STATS"; 
  INSERT INTO "SYS"."IMPDP_STATS" (type,version,flags,c1,c2,c3,c5,n1,n2,n3,n4,n9,n10,n11,n12,d1) VALUES ('T',6,2,t,p,sp,s,
               0,0,0,0,0,NULL,NULL,NULL,
               TO_DATE('2013-09-04 22:00:14',df));
  c := 'COL1'; 
  EXECUTE IMMEDIATE stmt USING 'C',t,p,sp,c,s,
               0,0,0,nv,0,nv,nv,0,0,nv,nv,
               TO_DATE('2013-09-04 22:00:14',df),nv,nv,nv,2,nv;
  c := 'COL2'; 
  EXECUTE IMMEDIATE stmt USING 'C',t,p,sp,c,s,
               0,0,0,nv,0,nv,nv,0,0,nv,nv,
               TO_DATE('2013-09-04 22:00:14',df),nv,nv,nv,2,nv;

  DBMS_STATS.IMPORT_TABLE_STATS('"ZWC"','"GGTEST"',NULL,'"IMPDP_STATS"',NULL,NULL,'"SYS"'); 
  DELETE FROM "SYS"."IMPDP_STATS"; 
END; 
/


你可能感兴趣的:(Oracle,Oracle)