Tuesday, September 24, 2013

TRANSFORM in ORACLE 11g DATAPUMP

                                  TRANSFORM in ORACLE 11g DATAPUMP

Purpose
Enables you to alter object creation DDL for objects being imported.
Syntax and Description
TRANSFORM = transform_name:value[:object_type]
The transform_name specifies the name of the transform. The possible options are as follows:
  • SEGMENT_ATTRIBUTES - If the value is specified as y, then segment attributes (physical attributes, storage attributes, tablespaces, and logging) are included, with appropriate DDL. The default is y.
  • STORAGE - If the value is specified as y, then the storage clauses are included, with appropriate DDL. The default is y. This parameter is ignored if SEGMENT_ATTRIBUTES=n.
  • OID - If the value is specified as n, then the assignment of the exported OID during the creation of object tables and types is inhibited. Instead, a new OID is assigned. This can be useful for cloning schemas, but does not affect referenced objects. The default value is y.
  • PCTSPACE - The value supplied for this transform must be a number greater than zero. It represents the percentage multiplier used to alter extent allocations and the size of data files.
Note that you can use the PCTSPACE transform with the Data Pump Export SAMPLE parameter so that the size of storage allocations matches the sampled data subset.
  • SEGMENT_CREATION - If set to y (the default), then this transform causes the SQL SEGMENT CREATION clause to be added to the CREATE TABLE statement. That is, the CREATE TABLE statement will explicitly say either SEGMENT CREATION DEFERRED or SEGMENT CREATION IMMEDIATE. If the value is n, then the SEGMENT CREATION clause is omitted from the CREATE TABLE statement. Set this parameter to n to use the default segment creation attributes for the table(s) being loaded. (This functionality is available starting with Oracle Database 11g release 2 (11.2.0.2).)
The type of value specified depends on the transform used. Boolean values (y/n) are required for the SEGMENT_ATTRIBUTESSTORAGE, and OID transforms. Integer values are required for the PCTSPACE transform.

The object_type is optional. If supplied, it designates the object type to which the transform will be applied. If no object type is specified, then the transform applies to all valid object types.

Valid Object Types For the Data Pump Import TRANSFORM Parameter
SEGMENT_ATTRIBUTES
STORAGE
OID
PCTSPACE
SEGMENT_CREATION
CLUSTER
X
X

X

CONSTRAINT
X
X

X

INC_TYPE


X


INDEX
X
X

X

ROLLBACK_SEGMENT
X
X

X

TABLE
X
X
X
X
X
TABLESPACE
X


X

TYPE


X




First lets assume we took the export  full or schema mode export.
$expdp full=y dumpfile=d1.dmp directory=dps

Case 1:  Normal import 

[oracle@racs dp]$ impdp tables=scott.emp dumpfile=d1.dmp directory=dps sqlfile=emp.sql

Import: Release 11.2.0.3.0 - Production on Tue Sep 24 09:49:19 2013

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

Username: dpusr
Password:

Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Master table "DPUSR"."SYS_SQL_FILE_TABLE_01" successfully loaded/unloaded
Starting "DPUSR"."SYS_SQL_FILE_TABLE_01":  dpusr/******** tables=scott.emp dumpfile=d1.dmp directory=dps sqlfile=emp.sql
Processing object type DATABASE_EXPORT/SCHEMA/TABLE/TABLE
Processing object type DATABASE_EXPORT/SCHEMA/TABLE/INDEX/INDEX
.......
Job "DPUSR"."SYS_SQL_FILE_TABLE_01" successfully completed at 09:49:31

[oracle@racs dp]$ vi emp.sql


CREATE TABLE "SCOTT"."EMP"
   (    "EMPNO" NUMBER(4,0),
        "ENAME" VARCHAR2(10 BYTE),
        "JOB" VARCHAR2(9 BYTE),
        "MGR" NUMBER(4,0),
        "HIREDATE" DATE,
        "SAL" NUMBER(7,2),
        "COMM" NUMBER(7,2),
        "DEPTNO" NUMBER(2,0)
   ) 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: DATABASE_EXPORT/SCHEMA/TABLE/INDEX/INDEX
-- CONNECT SCOTT
CREATE UNIQUE INDEX "SCOTT"."PK_EMP" ON "SCOTT"."EMP" ("EMPNO")
  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" PARALLEL 1 ;

  ALTER INDEX "SCOTT"."PK_EMP" NOPARALLEL;
-- new object type path: DATABASE_EXPORT/SCHEMA/TABLE/CONSTRAINT/CONSTRAINT
-- CONNECT DPUSR
ALTER TABLE "SCOTT"."EMP" ADD CONSTRAINT "PK_EMP" PRIMARY KEY ("EMPNO")
  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;

Using TRANSFORM option you can change or ignore these options.  Benefit is you may do not want similar metadata.  Forexample, tablespace name is pointing as USERS, current import user may be using different tablespace. As you know whenever we create a table , if your not specified the tablespace, it will take default user's tablespace.  If you want go like that case means you need to use TRANSFORM options. etc.

Case 2:  SEGMENT ATTRIBUTE option with N

 It will ignore all segment attributes(pink color) things for objects(you can verify the table for applicable objects). 

 [oracle@racs dp]$ impdp tables=scott.emp dumpfile=d1.dmp directory=dps sqlfile=emp_seg.sql transform=segment_attributes:n

Import: Release 11.2.0.3.0 - Production on Tue Sep 24 09:51:17 2013

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

Username: dpusr
Password:

Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Master table "DPUSR"."SYS_SQL_FILE_TABLE_01" successfully loaded/unloaded
Starting "DPUSR"."SYS_SQL_FILE_TABLE_01":  dpusr/******** tables=scott.emp dumpfile=d1.dmp directory=dps sqlfile=emp_seg.sql transform=segment_attributes:n
Processing object type DATABASE_EXPORT/SCHEMA/TABLE/TABLE
Processing object type DATABASE_EXPORT/SCHEMA/TABLE/INDEX/INDEX
....
Processing object type DATABASE_EXPORT/SCHEMA/TABLE/STATISTICS/TABLE_STATISTICS
Job "DPUSR"."SYS_SQL_FILE_TABLE_01" successfully completed at 09:51:30


[oracle@racs dp]$ vi emp_seg.sql
  CREATE TABLE "SCOTT"."EMP"
   (    "EMPNO" NUMBER(4,0),
        "ENAME" VARCHAR2(10 BYTE),
        "JOB" VARCHAR2(9 BYTE),
        "MGR" NUMBER(4,0),
        "HIREDATE" DATE,
        "SAL" NUMBER(7,2),
        "COMM" NUMBER(7,2),
        "DEPTNO" NUMBER(2,0)
   ) ;
-- new object type path: DATABASE_EXPORT/SCHEMA/TABLE/INDEX/INDEX
-- CONNECT SCOTT
CREATE UNIQUE INDEX "SCOTT"."PK_EMP" ON "SCOTT"."EMP" ("EMPNO")
  ;

  ALTER INDEX "SCOTT"."PK_EMP" NOPARALLEL;
-- new object type path: DATABASE_EXPORT/SCHEMA/TABLE/CONSTRAINT/CONSTRAINT
-- CONNECT DPUSR
ALTER TABLE "SCOTT"."EMP" ADD CONSTRAINT "PK_EMP" PRIMARY KEY ("EMPNO") ENABLE;
-- new object type path: DATABASE_EXPORT/SCHEMA/TABLE/INDEX/STATISTICS/INDEX_STATISTICS

Now everything is default.   

Case 3: ignore SEGMENT ATTRIBUTES FOR TABLE

[oracle@racs dp]$ impdp tables=scott.emp dumpfile=d1.dmp directory=dps sqlfile=emp_seg_tab.sql transform=segment_attributes:n:table

Import: Release 11.2.0.3.0 - Production on Tue Sep 24 09:52:47 2013

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

Username: dpusr
Password:

Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Master table "DPUSR"."SYS_SQL_FILE_TABLE_01" successfully loaded/unloaded
Starting "DPUSR"."SYS_SQL_FILE_TABLE_01":  dpusr/******** tables=scott.emp dumpfile=d1.dmp directory=dps sqlfile=emp_seg_tab.sql transform=segment_attributes:n:table
Processing object type DATABASE_EXPORT/SCHEMA/TABLE/TABLE
Processing object type DATABASE_EXPORT/SCHEMA/TABLE/INDEX/INDEX
....
Processing object type DATABASE_EXPORT/SCHEMA/TABLE/STATISTICS/TABLE_STATISTICS
Job "DPUSR"."SYS_SQL_FILE_TABLE_01" successfully completed at 09:52:59

[oracle@racs dp]$ vi emp_seg_tab.sql


CREATE TABLE "SCOTT"."EMP"
   (    "EMPNO" NUMBER(4,0),
        "ENAME" VARCHAR2(10 BYTE),
        "JOB" VARCHAR2(9 BYTE),
        "MGR" NUMBER(4,0),
        "HIREDATE" DATE,
        "SAL" NUMBER(7,2),
        "COMM" NUMBER(7,2),
        "DEPTNO" NUMBER(2,0)
   ) ;
-- new object type path: DATABASE_EXPORT/SCHEMA/TABLE/INDEX/INDEX
-- CONNECT SCOTT
CREATE UNIQUE INDEX "SCOTT"."PK_EMP" ON "SCOTT"."EMP" ("EMPNO")
  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" PARALLEL 1 ;

  ALTER INDEX "SCOTT"."PK_EMP" NOPARALLEL;
-- new object type path: DATABASE_EXPORT/SCHEMA/TABLE/CONSTRAINT/CONSTRAINT
-- CONNECT DPUSR
ALTER TABLE "SCOTT"."EMP" ADD CONSTRAINT "PK_EMP" PRIMARY KEY ("EMPNO")
  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;

Note:  Now attributes are ignored for table only.

Case 4: IGNORE SEGMENT ATTRIBUTES FOR INDEX

  [oracle@racs dp]$ impdp tables=scott.emp dumpfile=d1.dmp directory=dps sqlfile=emp_seg_ind.sql transform=segment_attributes:n:index

Import: Release 11.2.0.3.0 - Production on Tue Sep 24 09:53:51 2013
Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

Username: dpusr
Password:
Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Master table "DPUSR"."SYS_SQL_FILE_TABLE_01" successfully loaded/unloaded
Starting "DPUSR"."SYS_SQL_FILE_TABLE_01":  dpusr/******** tables=scott.emp dumpfile=d1.dmp directory=dps sqlfile=emp_seg_ind.sql transform=segment_attributes:n:index
Processing object type DATABASE_EXPORT/SCHEMA/TABLE/TABLE
Processing object type DATABASE_EXPORT/SCHEMA/TABLE/INDEX/INDEX
.....
Processing object type DATABASE_EXPORT/SCHEMA/TABLE/STATISTICS/TABLE_STATISTICS
Job "DPUSR"."SYS_SQL_FILE_TABLE_01" successfully completed at 09:54:01

[oracle@racs dp]$ vi emp_seg_ind.sql
 
  CREATE TABLE "SCOTT"."EMP"
   (    "EMPNO" NUMBER(4,0),
        "ENAME" VARCHAR2(10 BYTE),
        "JOB" VARCHAR2(9 BYTE),
        "MGR" NUMBER(4,0),
        "HIREDATE" DATE,
        "SAL" NUMBER(7,2),
        "COMM" NUMBER(7,2),
        "DEPTNO" NUMBER(2,0)
   ) 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: DATABASE_EXPORT/SCHEMA/TABLE/INDEX/INDEX
-- CONNECT SCOTT
CREATE UNIQUE INDEX "SCOTT"."PK_EMP" ON "SCOTT"."EMP" ("EMPNO")
  ;
  ALTER INDEX "SCOTT"."PK_EMP" NOPARALLEL;
-- new object type path: DATABASE_EXPORT/SCHEMA/TABLE/CONSTRAINT/CONSTRAINT
-- CONNECT DPUSR
ALTER TABLE "SCOTT"."EMP" ADD CONSTRAINT "PK_EMP" PRIMARY KEY ("EMPNO")
  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;

Note:  Now indexes are ignored attributes.

Case 5: IGNORE THE STORGE

By default objects will get

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)

  [oracle@racs dp]$ impdp tables=scott.emp dumpfile=d1.dmp directory=dps sqlfile=emp_sto.sql transform=storage:n

Import: Release 11.2.0.3.0 - Production on Tue Sep 24 10:03:40 2013
Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

Username: dpusr
Password:
Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Master table "DPUSR"."SYS_SQL_FILE_TABLE_01" successfully loaded/unloaded
Starting "DPUSR"."SYS_SQL_FILE_TABLE_01":  dpusr/******** tables=scott.emp dumpfile=d1.dmp directory=dps sqlfile=emp_sto.sql transform=storage:n
Processing object type DATABASE_EXPORT/SCHEMA/TABLE/TABLE
Processing object type DATABASE_EXPORT/SCHEMA/TABLE/INDEX/INDEX
....
Processing object type DATABASE_EXPORT/SCHEMA/TABLE/STATISTICS/TABLE_STATISTICS
Job "DPUSR"."SYS_SQL_FILE_TABLE_01" successfully completed at 10:03:53

[oracle@racs dp]$ vi emp_sto.sql


  CREATE TABLE "SCOTT"."EMP"
   (    "EMPNO" NUMBER(4,0),
        "ENAME" VARCHAR2(10 BYTE),
        "JOB" VARCHAR2(9 BYTE),
        "MGR" NUMBER(4,0),
        "HIREDATE" DATE,
        "SAL" NUMBER(7,2),
        "COMM" NUMBER(7,2),
        "DEPTNO" NUMBER(2,0)
   ) SEGMENT CREATION IMMEDIATE
  PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
 NOCOMPRESS LOGGING
  TABLESPACE "USERS" ;
-- new object type path: DATABASE_EXPORT/SCHEMA/TABLE/INDEX/INDEX
-- CONNECT SCOTT
CREATE UNIQUE INDEX "SCOTT"."PK_EMP" ON "SCOTT"."EMP" ("EMPNO")
  PCTFREE 10 INITRANS 2 MAXTRANS 255
  TABLESPACE "USERS" PARALLEL 1 ;

  ALTER INDEX "SCOTT"."PK_EMP" NOPARALLEL;
-- new object type path: DATABASE_EXPORT/SCHEMA/TABLE/CONSTRAINT/CONSTRAINT
-- CONNECT DPUSR
ALTER TABLE "SCOTT"."EMP" ADD CONSTRAINT "PK_EMP" PRIMARY KEY ("EMPNO")
  USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255
  TABLESPACE "USERS"  ENABLE;

Note: Now its ignored storage .


Case 6: Change the PCTSPACE.

PCTSPACE parameter helpful to either reduce/increase the storage space.  Whatever value you put(interms of percentage), based on metadata value its resize.

For example,  EMP table pct space is 

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)

now pctspace=10  means it will initially allocates 10% extents and also for next extent, while importing the data.

[oracle@racs dp]$ impdp tables=scott.emp dumpfile=d1.dmp directory=dps sqlfile=emp_pct_tab.sql  transform=pctspace:10
Import: Release 11.2.0.3.0 - Production on Tue Sep 24 10:38:42 2013
Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

Username: dpusr
Password:
Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Master table "DPUSR"."SYS_SQL_FILE_TABLE_01" successfully loaded/unloaded
Starting "DPUSR"."SYS_SQL_FILE_TABLE_01":  dpusr/******** tables=scott.emp dumpfile=d1.dmp directory=dps sqlfile=emp_pct_tab.sql transform=pctspace:10
Processing object type DATABASE_EXPORT/SCHEMA/TABLE/TABLE
Processing object type DATABASE_EXPORT/SCHEMA/TABLE/INDEX/INDEX
...
Processing object type DATABASE_EXPORT/SCHEMA/TABLE/STATISTICS/TABLE_STATISTICS
Job "DPUSR"."SYS_SQL_FILE_TABLE_01" successfully completed at 10:38:55
[oracle@racs dp]$ vi emp_pct_tab.sql

CREATE TABLE "SCOTT"."EMP"
   (    "EMPNO" NUMBER(4,0),
        "ENAME" VARCHAR2(10 BYTE),
        "JOB" VARCHAR2(9 BYTE),
        "MGR" NUMBER(4,0),
        "HIREDATE" DATE,
        "SAL" NUMBER(7,2),
        "COMM" NUMBER(7,2),
        "DEPTNO" NUMBER(2,0)
   ) SEGMENT CREATION IMMEDIATE
  PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
 NOCOMPRESS LOGGING
  STORAGE(INITIAL 6554 NEXT 104858 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: DATABASE_EXPORT/SCHEMA/TABLE/INDEX/INDEX
-- CONNECT SCOTT
CREATE UNIQUE INDEX "SCOTT"."PK_EMP" ON "SCOTT"."EMP" ("EMPNO")
  PCTFREE 10 INITRANS 2 MAXTRANS 255
  STORAGE(INITIAL 6554 NEXT 104858 MINEXTENTS 1 MAXEXTENTS 2147483645
  PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1
  BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
  TABLESPACE "USERS" PARALLEL 1 ;

  ALTER INDEX "SCOTT"."PK_EMP" NOPARALLEL;
-- new object type path: DATABASE_EXPORT/SCHEMA/TABLE/CONSTRAINT/CONSTRAINT
-- CONNECT DPUSR
ALTER TABLE "SCOTT"."EMP" ADD CONSTRAINT "PK_EMP" PRIMARY KEY ("EMPNO")
  USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255
  STORAGE(INITIAL 6554 NEXT 104858 MINEXTENTS 1 MAXEXTENTS 2147483645
  PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1
  BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
  TABLESPACE "USERS"  ENABLE;

Now you can compare these values without pctspace option.

CASE 7: OID

SQL> SELECT SYS_OP_GUID() FROM DUAL;


SYS_OP_GUID()
--------------------------------
CF8C98BA272CA45CE0400C0A8D67761

CREATE TYPE APPtypes OID 'TESTOID'
AS OBJECT (attrib1 NUMBER);

SQL> CREATE TYPE APPtypes OID 'CF8C98BA272CA45CE0400C0A8D67761'
     AS OBJECT (attrib1 NUMBER);
     /

Type created.

SQL> select TYPE_NAME, TYPE_OID from user_types where TYPE_NAME='APPTYPES';

TYPE_NAME                      TYPE_OID
------------------------------ --------------------------------
APPTYPE                        CF8C98BA272CA45CE0400C0A8D67761

Taking the export of only TYPE objects from the schema using include option

expdp job_name=schemaexp1s schemas=scott include=type dumpfile=exp_types.dmp logfile=exp_type.log directory=dps compression=all

Export: Release 11.2.0.2.0 - Production on Wed Nov 28 05:31:07 2012

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

Username: / as sysdba

Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options
Starting "SYS"."SCHEMAEXP1":  /******** AS SYSDBA job_name=schemaexp1 schemas=scott include=type dumpfile=exp_types.dmp logfile=exp_type.log directory=dps compression=all
Estimate in progress using BLOCKS method...
Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 0 KB
Processing object type SCHEMA_EXPORT/TYPE/TYPE_SPEC
Master table "SYS"."SCHEMAEXP1" successfully loaded/unloaded
******************************************************************************
Dump file set for SYS.SCHEMAEXP1 is:
  /u01/backup1/export/exp_types.dmp
Job "SYS"."SCHEMAEXP1" successfully completed at 05:31:17

Dropping the type
SQL> drop type APPTYPE;

Type dropped.

Importing the type object with transform=OID:n:type which will create the type object with new OID value.
$ impdp dumpfile=exp_types.dmp logfile=imp_exp_type.log directory=dps full=y transform=OID:n:type

Import: Release 11.2.0.2.0 - Production on Wed Nov 28 05:34:40 2012

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

Username: / as sysdba

Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options
Master table "SYS"."SYS_IMPORT_FULL_01" successfully loaded/unloaded
Starting "SYS"."SYS_IMPORT_FULL_01":  /******** AS SYSDBA dumpfile=exp_types.dmp logfile=imp_exp_type.log directory=dps full=y transform=OID:n:type
Processing object type SCHEMA_EXPORT/TYPE/TYPE_SPEC
Job "SYS"."SYS_IMPORT_FULL_01" successfully completed at 05:34:45

Object created with new OID value.
SQL> select TYPE_NAME, TYPE_OID from user_types where TYPE_NAME='APPTYPES';


TYPE_NAME                      TYPE_OID
------------------------------ --------------------------------
APPTYPE                        CF8CB70D75454DAE0400C0A8D671725

SQL> drop type APPTYPE;

Type dropped.
Importing the dump with transform=OID:y:type which will maintain the same OID values during the export.

$ impdp dumpfile=exp_types.dmp logfile=imp_exp_type.log directory=dps full=y transform=OID:y:type

Import: Release 11.2.0.2.0 - Production on Wed Nov 28 05:35:47 2012

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

Username: / as sysdba

Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options
Master table "SYS"."SYS_IMPORT_FULL_01" successfully loaded/unloaded
Starting "SYS"."SYS_IMPORT_FULL_01":  /******** AS SYSDBA dumpfile=exp_type.dmp logfile=imp_exp_type.log directory=EXP_DIR full=y transform=OID:y:type
Processing object type SCHEMA_EXPORT/TYPE/TYPE_SPEC
Job "SYS"."SYS_IMPORT_FULL_01" successfully completed at 05:35:56

Type object imported with same OID during the export.
SQL> select TYPE_NAME, TYPE_OID from user_types where TYPE_NAME='APPTYPE';

TYPE_NAME                      TYPE_OID
------------------------------ --------------------------------
APPTYPE                        CF8C98BA272CA45CE0400C0A8D67761

2 comments:

  1. This is very clear and detailed explanation of transform option , Thanks

    ReplyDelete

Share your knowledge it really improves, don't show off...