--查詢數據泵使用的目錄
SQL> select * from dba_directories;
--導出數據庫使用的導出目錄
EXPDP_DUMP
/u02/expdp_dump
--導出scott下表T_A的命令
expdp system/oracle directory=expdp_dump dumpfile=expdp_T_A.dmp logfile=expdp_T_A.log tables=scott.T_A
--導出操作記錄
[oracle@test196 ~]$ expdp system/oracle directory=expdp_dump dumpfile=expdp_T_A.dmp logfile=expdp_T_A.log tables= scott.T_A
Export: Release 11.2.0.3.0 - Production on Thu May 4 09:30:13 2017
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Starting "SYSTEM"."SYS_EXPORT_TABLE_01": system/******** directory=expdp_dump dumpfile=expdp_T_A.dmp logfile=expdp_T_A.log tables= scott.T_A
Estimate in progress using BLOCKS method...
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 243 MB
Processing object type TABLE_EXPORT/TABLE/TABLE
Processing object type TABLE_EXPORT/TABLE/COMMENT
Processing object type TABLE_EXPORT/TABLE/CONSTRAINT/CONSTRAINT
Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
. . exported "SCOTT"." T_A " 165.6 MB 12661 rows
Master table "SYSTEM"."SYS_EXPORT_TABLE_01" successfully loaded/unloaded
******************************************************************************
Dump file set for SYSTEM.SYS_EXPORT_TABLE_01 is:
/u02/expdp_dump/expdp_T_A.dmp
Job "SYSTEM"."SYS_EXPORT_TABLE_01" successfully completed at 09:31:00
[oracle@test196 ~]$ cd /u02/expdp_dump/
[oracle@test196 expdp_dump]$ ls -l|grep JOB
-rw-r----- 1 oracle oinstall 173830144 May 4 09:31 expdp_T_A.dmp
-rw-r--r-- 1 oracle oinstall 1283 May 4 09:31 expdp_T_A.log
[oracle@test196 expdp_dump]$
--導出文件傳輸到要導入的數據庫
[oracle@test196 expdp_dump]$scp expdp_T_A.dmp oracle@192.168.160.191: /oracle/expdp/
The authenticity of host '192.168.160.191 (192.168.160.191)' can't be established.
RSA key fingerprint is 25:eb:f3:8d:a8:ce:02:67:d1:f7:2a:3c:99:c4:71:d0.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.160.191' (RSA) to the list of known hosts.
oracle@192.168.160.191's password:
expdp_T_A.dmp 100% 166MB 11.1MB/s 00:15
[oracle@test196 expdp_dump]$
--查詢數據泵使用的目錄
SQL> select * from dba_directories;
導入使用的目錄
192.168.160.191
DUMP
/oracle/expdp/
--導入scott下的命令(表名保持不變)
impdp system/oracle directory=dump dumpfile=expdp_T_A.dmp logfile= t_a.log TABLES=scott.T_A
--導入操作記錄
[oracle@test01 ~]$ cd /oracle/expdp/
[oracle@test01 expdp]$ ls -lh|grep JOB
-rw-r----- 1 oracle oinstall 166M May 4 09:41 expdp_T_A.dmp
[oracle@test01 expdp]$
[oracle@test01 expdp]$ impdp system/oracle directory=dump dumpfile=expdp_T_A.dmp logfile= t_a.log TABLES=scott.T_A
Import: Release 12.2.0.1.0 - Production on Thu May 4 09:53:05 2017
Copyright (c) 1982, 2017, Oracle and/or its affiliates. All rights reserved.
Connected to: Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
Master table "SYSTEM"."SYS_IMPORT_TABLE_01" successfully loaded/unloaded
Starting "SYSTEM"."SYS_IMPORT_TABLE_01": system/******** directory=dump dumpfile=expdp_T_A.dmp logfile=t_a.log TABLES=scott.T_A
Processing object type TABLE_EXPORT/TABLE/TABLE
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
. . imported "SCOTT"."T_A" 165.6 MB 12661 rows
Processing object type TABLE_EXPORT/TABLE/COMMENT
Processing object type TABLE_EXPORT/TABLE/CONSTRAINT/CONSTRAINT
Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
Job "SYSTEM"."SYS_IMPORT_TABLE_01" successfully completed at Thu May 4 09:53:41 2017 elapsed 0 00:00:35
[oracle@test01 expdp]$
導入完成后可以在導入的數據庫scott下查詢到表T_A
--導入scott下的命令(表重命名)
impdp system/oracle directory=dump dumpfile=expdp_T_A.dmp logfile= t_a.log REMAP_TABLE=scott.T_A:EMPS
--導入操作記錄
[oracle@test01 expdp]$ impdp system/oracle directory=dump dumpfile=expdp_T_A.dmp logfile= t_a.log REMAP_TABLE=scott.T_A:EMPS
Import: Release 12.2.0.1.0 - Production on Thu May 4 09:50:52 2017
Copyright (c) 1982, 2017, Oracle and/or its affiliates. All rights reserved.
Connected to: Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
Master table "SYSTEM"."SYS_IMPORT_FULL_01" successfully loaded/unloaded
Starting "SYSTEM"."SYS_IMPORT_FULL_01": system/******** directory=dump dumpfile=expdp_T_A.dmp logfile=t_case.log REMAP_TABLE=jobbackup.T_A:EMPS
Processing object type TABLE_EXPORT/TABLE/TABLE
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
. . imported "JOBBACKUP"."EMPS" 165.6 MB 12661 rows
Processing object type TABLE_EXPORT/TABLE/COMMENT
Processing object type TABLE_EXPORT/TABLE/CONSTRAINT/CONSTRAINT
Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
Job "SYSTEM"."SYS_IMPORT_FULL_01" successfully completed at Thu May 4 09:51:34 2017 elapsed 0 00:00:37
導入完成后可以在導入的數據庫scott下查詢到表EMPS
-----2017-11-01 18:08-----
導出指定schema的一個表,導入到一個新的schema下並重命名
--在源庫中導出指定schema的一個表的數據
expdp system/oracle directory=EXPDUMP dumpfile=expdp_scott_1017$rq.dmp logfile=expdp_scott_1017$rq.log TABLES=hr.t_A;
--通過scp或其他方式傳到目標庫
--將導出文件導入到一個新的schema下,並更改成新的表空間
impdp system/oracle directory=DP_DIR dumpfile=expdp_scott_1017.dmp logfile= t_expdp_scott_1017.log remap_schema=hr:SCOTT REMAP_TABLESPACE=TBS_HR:TBS_SCOTT
--將導出文件導入到一個新的schema下重命名表名,並更改成新的表空間
impdp system/oracle directory=DP_DIR dumpfile=expdp_scott_1017.dmp logfile= t_expdp_scott_1017.log remap_schema=hr:SCOTT REMAP_TABLESPACE=TBS_HR:TBS_SCOTT REMAP_TABLE=hr.t_A:t_BBB
