倒出需要的表(可以先建立需要导出的表清单):
expdp 9959/www@sgcrm5_204 directory=DATA_EXP dumpfile=expdp_sgcrm5_%U.bak logfile=expdp_%U.log INCLUDE=TABLE:\"IN \(SELECT table_name FROM dba_tables where owner='9959' and TEMPORARY='N' and table_name not like 'TB20%'\)\"
排除不要的表:
expdp scott/tiger@prod directory=dump_dir dumpfile=sec.dmp logfile=sec.log EXCLUDE=TABLE:\"IN\(\'T1\',\'T2\'\)\"
只倒出表结构:
expdp CONTENT=METADATA_ONLY INCLUDE=TABLE
Set heading off
Set feedback off
Spool test01.txt
Select 'tables=('||chr(10) from dual;
Select owner||'.'||table_name||chr(10) || ',' from dba_tables where owner='9959' and table_name not in ('xx','xxx');
Select 'dual' from dual;
Spool off
上述的chr(10)是换行符,可以在parfile中正常使用,但是如果单独的复制到命令模式下,则oracle会认为是结束命令而报错。
然后将生成的test01.txt文件的内容复制到parfile文件中。
Parfile text01.par
File=(d:text01.dmp,d:text02.dmp,d:text03.dmp) log=text01.log filesize=512M buffer=10240000 direct=y tables=(
SYS.CON$,
SYS.UNDO$,
SYS.CDEF$,
...
dual)
direct=y直接导出模式,很多网友谈到了buffer和direct的设置,direct=y绕过了sql命令处理层,加快了导出速度。
impdp userid=\"/ as sysdba\" DIRECTORY=DATA_EXP parallel=4 DUMPFILE=expdp_sgcrm5_01.bak,expdp_sgcrm5_02.bak,expdp_sgcrm5_03.bak,expdp_sgcrm5_04.bak,expdp_sgcrm5_05.bak,expdp_sgcrm5_06.bak logfile=sgcrm5_`date +%b_%d_%H_%M_%S`.log REMAP_TABLESPACE=DAT_AUTO_01:DATA9959,DAT_AUTO_02:DATA9959
impdp userid=\"/ as sysdba\" DIRECTORY=DATA_EXP DUMPFILE=sgerp5_01.bak logfile=impdp_sgerp5_`date +%b_%d_%H_%M_%S`.log.log REMAP_TABLESPACE=SGERP5DATA02:DATA01,SGERP5DATA01:DATA01,SGERP5INDATA:DATA01,SGERP5DATA:DATA01 SGERP5INDATA01:DATA01 SGERP5INDATA02:DATA01