使用impdp将源库下的部分数据 导入 到目标库中

使用impdp将一个用户下的表导入到另一个用户下
源库上 按照schema导出
export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
expdp system/oracle  directory=EXPDP schemas=news dumpfile=20151227expnews.dmp logfile=20151227expnews.log


目标库上使用remap_schema导入
export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
impdp system/oracle111  directory=EXPDP dumpfile=20151227expnews.dmp schemas=news remap_schema=news:kash remap_tablespace=paytbs:kash_tbs logfile=20151227impkash.log



使用impdp将一个用户下的部分表导入到目标库另一个用户下
源库上使用tables将需要导出的表以,号分开,导出
export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
expdp system/oracle  directory=EXPDP tables=news.CONFIG,news.CONFIG_LOG,news.APPLY,news.INFO dumpfile=20160104expnews4tables.dmp logfile=20160104expnews4tables.log


目标库上导入,使用remap_schema代替imp中的fromuser,touser选项,使用remap_tablespace来表示将导入的表创建在哪个新的表空间中
export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
impdp system/oracle111  directory=EXPDP dumpfile=20160104expnews4tables.dmp tables=news.CONFIG,news.CONFIG_LOG,news.APPLY,news.INFO  remap_schema=news:kash remap_tablespace=paytbs:kash_tbs logfile=20160104expnews4tables.log



使用impdp将源库一个表的部分数据导入到目标库中
源库上使用query语句 \为转义符,导出部分数据。
export LANG=AMERICAN_AMERICA.ZHS16GBK
expdp system/oracle  directory=EXPDP tables=b.b_file query=\" WHERE file_id IN\(\'785\',\'786\',\'787\',\'788\',\'789\',\'790\',\'791\'\)\" dumpfile=20160104expdpb_file.dmp logfile=20160104expdpb_file.log 


目标库上导入
export LANG=AMERICAN_AMERICA.ZHS16GBK

impdp system/oracle111 directory=EXPDP  tables=b.b_file dumpfile=20160104expdpb_file.dmp TABLE_EXISTS_ACTION=APPEND logfile=20160104impdpb_file.log 


【在远端直接导入】
expdp system/oracle directory=EXPDPBD dumpfile=rptest_1tablespace_20160520.dmp TABLESPACES=myts network_link='DBLINK_RP' logfile=rptest_1tablespace_20160520.log


源端:
RAN                            USERS


目标端
create tablespace mydemo datafile '/u01/app/oracle/oradata/ora11g/mydemo01.dbf' size 100M;
create user sender identified by oracle  default tablespace mydemo;
grant connect,resource to sender;


需求:
将源端的ran用户下的表 导入到 本地的sender用户下。使用network_link参数


impdp system/oracle schemas=ran remap_schema=ran:sender remap_tablespace=users:mydemo,myts:mydemo network_link='DBLINK_RP' logfile=rptest_1tablespace_2016052001.log





[ora11g@instance ~]$ impdp system/oracle schemas=ran remap_schema=ran:sender remap_tablespace=users:mydemo,myts:mydemo network_link='DBLINK_RP' logfile=rptest_1tablespace_2016052001.log


Import: Release 11.2.0.4.0 - Production on Sat May 21 00:06:00 2016


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
Starting "SYSTEM"."SYS_IMPORT_SCHEMA_02":  system/******** schemas=ran remap_schema=ran:sender remap_tablespace=users:mydemo,myts:mydemo network_link=DBLINK_RP logfile=rptest_1tablespace_2016052001.log 
Estimate in progress using BLOCKS method...
Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 192 KB
Processing object type SCHEMA_EXPORT/USER
ORA-31684: Object type USER:"SENDER" already exists
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
. . imported "SENDER"."T2"                                    4 rows
. . imported "SENDER"."T3"                                    4 rows
. . imported "SENDER"."TEST"                                  4 rows
Processing object type SCHEMA_EXPORT/TABLE/CONSTRAINT/CONSTRAINT
Processing object type SCHEMA_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
Job "SYSTEM"."SYS_IMPORT_SCHEMA_02" completed with 1 error(s) at Sat May 21 00:06:55 2016 elapsed 0 00:00:55

你可能感兴趣的:(11g,学习)