impdp的transform参数去掉表空间和存储⼦句解决导⼊时报错
或空间不⾜问题
要将SLKTESTNEW模式下的表导⼊到另⼀个库下的SH_SMCVDMS_SLK_OWSLK模式下。
该模式下对象实际所占的⼤⼩:
SQL> lect sum(bytes)/1024/1024 from dba_gments where owner=upper('SLKTESTNEW');
SUM(BYTES)/1024/1024
--------------------
11747.25 -----------很⼤,会计算所有hwm下的block
导出语句:
expdp system/1111sys directory=dmpdata SCHEMAS=SLKTESTNEW dumpfile=owslk20110630.dmp logfile=owslk20110630.log
导出数据后的dmp⼤⼩:
$ du -m OWSLK20110630.DMP
80.63 OWSLK20110630.DMP ----很⼩,因为expdp只把有效block导出
若不加transform,且导⼊的表空间⼩于前⾯计算的11747.25,中间报错:
ORA-01659: unable to allocate MINEXTENTS beyond 14 in tablespace SH_SMCVDMS_SLK_OWSLK_DATA01。
也不必为了80M的数据再加⼊11G的空间。那就⽤impdp的transform 选项实现导⼊。
impdp的transform 选项决定是否去掉ddl语句的各种存储参数
Purpo
Enables you to alter object creation DDL for specific objects, as well as for all applicable objects being loaded.
Metadata transform to apply to applicable objects. Valid transform keywords: SEGMENT_ATTRIBUTES, STORAGE,OID, and PCTSPACE
Syntax and Description
TRANSFORM = transform_name:value[:object_type]
例如:transform=storage:n:table ,去掉ddl的storage参数,只对table有效,若没有table这个⼦句的话,就对所有对象有效,⽐如index
sql_file 选项加⼊后只是模拟导⼊过程,形成sql脚本,不会真正的导⼊。通过脚本可查看storage选项是否存在,gment_attributes是否存在。
使⽤transform可降低导⼊数据的存储需求,⽐如若源数据需要30G的表空间,但导出数据后只有300M,再导⼊的时候不必分配30G,由于transform起作⽤,把storage去掉了。
这⾥尤其指出的是在11.2.0.2以上有个新增的参数,SEGMENT_CREATION,如果设置其为n的话,ddl语句就不包含SEGMENT CREATION IMMEDIATE字段。
transform=storage:n
transform=oid:n
transform=gment_attributes:n
TRANSFORM=SEGMENT_CREATION:n
举例:
没指定transform,导⼊形成的dll
CREATE TABLE "SH_SMCVDMS_SLK_OWSLK"."DE_DEMESSAGEIDMAP"
( "DEMESSAGEID" CHAR(40) NOT NULL ENABLE,
..................................
"UPDATE_BY" CHAR(10)
) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
STORAGE(INITIAL 2952790016 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 -----先要初始化这么⼤的空间出来,这个不必要。若空间不⾜导⼊会终⽌
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
TABLESPACE "SH_SMCVDMS_SLK_OWSLK_DATA01" ;
加⼊了transform=storage:n
CREATE TABLE "SH_SMCVDMS_SLK_OWSLK"."DE_DEMESSAGEIDMAP"
( "DEMESSAGEID" CHAR(40) NOT NULL ENABLE,
..................................
"UPDATE_BY" CHAR(10)
) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
TABLESPACE "SH_SMCVDMS_SLK_OWSLK_DATA01" ; ------------把storage部分去掉了,这样可不必需要那么多的空间,按数据库默认的initial 64k.
加⼊了transform=gment_attributes:n
CREATE TABLE "SH_SMCVDMS_SLK_OWSLK"."DE_DEMESSAGEIDMAP"
( "DEMESSAGEID" CHAR(40) NOT NULL ENABLE,
..................................
"UPDATE_BY" CHAR(10)
) ; ---------------这个很⼲净了,create table的时候都是使⽤数据库的默认存储参数,表空间也使⽤的是⽤户默认表空间
---模拟导⼊,形成sql脚本:
impdp system/1111directory=dmp transform=storage:n REMAP_SCHEMA="SLKTESTNEW:sh_smcvdms_slk_owslk"
remap_tablespace="SH_DMS_SLK_OWSGM_DATA01:sh_smcvdms_slk_owslk_data01"
remap_tablespace="SH_DMS_SLK_OWSGM_LOB01:SH_SMCVDMS_SLK_OWSLK_LOB01" dumpfile=OWSLK20110630.DMP logfile=owslk20110702_storage_n.log sqlfile=owslk0702_storage_n.sql
----真正导⼊:
impdp system/1111 directory=dmp transform=storage:n REMAP_SCHEMA="SLKTESTNEW:sh_smcvdms_slk_owslk"
remap_tablespace="SH_DMS_SLK_OWSGM_DATA01:sh_smcvdms_slk_owslk_data01"
remap_tablespace="SH_DMS_SLK_OWSGM_LOB01:SH_SMCVDMS_SLK_OWSLK_LOB01" dumpfile=OWSLK20110630.DMP logfile=owslk20110702_storage_n.log table_exists_action=replace
====end=====
impdp c/c directory=expdp_dir dumpfile=c_expdp.dmp sqlfile=c_expdp.sql transform=gment_attributes:n