【EXPDP/IMPDP】使用 EXPDP/IMPDP工具“模糊”匯出和匯入
在《【EXP/IMP】使用EXP /IMP工具“模糊”匯出和匯入》(http://space.itpub.net/519536/viewspace-629537)文章中提到EXP 與IMP工具對錶的模糊匯出與匯入功能,EXPDP和IMPDP具有同樣的功能。
簡單演示,供參考。
注意萬用字元“_”含義。
1.環境準備
1)建立6張表,注意表名的規律。
sec@ora10g> create table TEST_SEC as select * from all_objects;
sec@ora10g> create table TEST_SEC1 as select * from all_objects;
sec@ora10g> create table TEST_SEC2 as select * from all_objects;
sec@ora10g> create table T_SEC as select * from all_objects;
sec@ora10g> create table T_SEC1 as select * from all_objects;
sec@ora10g> create table T_SEC2 as select * from all_objects;
2)檢視sec使用者下所有的表名
sec@ora10g> select * from tab;
TNAME TABTYPE CLUSTERID
------------------------------ ------- ----------
TEST_SEC TABLE
TEST_SEC2 TABLE
TEST_SEC1 TABLE
T_SEC TABLE
T_SEC1 TABLE
T_SEC2 TABLE
6 rows selected.
2.思考一下使用下面的模糊匯出後為什麼sec使用者下所有的表均被包含在內
ora10g@secDB /expdp$ expdp sec/sec directory=expdp_dir dumpfile=sec.dmp tables=T_S%
Export: Release 10.2.0.3.0 - 64bit Production on Saturday, 09 April, 2010 5:55:16
Copyright (c) 2003, 2005, Oracle. All rights reserved.
Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bit Production
With the Partitioning, Oracle Label Security, OLAP and Data Mining Scoring Engine options
Starting "SEC"."SYS_EXPORT_TABLE_01": sec/******** directory=expdp_dir dumpfile=sec.dmp tables=T_S%
Estimate in progress using BLOCKS method...
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 12 MB
Processing object type TABLE_EXPORT/TABLE/TABLE
Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
. . exported "SEC"."TEST_SEC" 1.013 MB 11678 rows
. . exported "SEC"."TEST_SEC1" 1.013 MB 11678 rows
. . exported "SEC"."TEST_SEC2" 1.013 MB 11678 rows
. . exported "SEC"."T_SEC" 1.013 MB 11678 rows
. . exported "SEC"."T_SEC1" 1.013 MB 11678 rows
. . exported "SEC"."T_SEC2" 1.013 MB 11678 rows
Master table "SEC"."SYS_EXPORT_TABLE_01" successfully loaded/unloaded
******************************************************************************
Dump file set for SEC.SYS_EXPORT_TABLE_01 is:
/expdp/sec.dmp
Job "SEC"."SYS_EXPORT_TABLE_01" successfully completed at 05:55:22
這裡是一個“美麗的誤會”,本意是想備份所有以“T_S”開頭的表,但是我們建立的6張表均被囊括在內了。根本原因是此處的下劃線“_”表示的是萬用字元!
3.僅備份以“TEST”開始的表
ora10g@secDB /expdp$ expdp sec/sec directory=expdp_dir dumpfile=sec.dmp tables=TEST%
Export: Release 10.2.0.3.0 - 64bit Production on Saturday, 09 April, 2010 5:55:51
Copyright (c) 2003, 2005, Oracle. All rights reserved.
Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bit Production
With the Partitioning, Oracle Label Security, OLAP and Data Mining Scoring Engine options
Starting "SEC"."SYS_EXPORT_TABLE_01": sec/******** directory=expdp_dir dumpfile=sec.dmp tables=TEST%
Estimate in progress using BLOCKS method...
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 6 MB
Processing object type TABLE_EXPORT/TABLE/TABLE
Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
. . exported "SEC"."TEST_SEC" 1.013 MB 11678 rows
. . exported "SEC"."TEST_SEC1" 1.013 MB 11678 rows
. . exported "SEC"."TEST_SEC2" 1.013 MB 11678 rows
Master table "SEC"."SYS_EXPORT_TABLE_01" successfully loaded/unloaded
******************************************************************************
Dump file set for SEC.SYS_EXPORT_TABLE_01 is:
/expdp/sec.dmp
Job "SEC"."SYS_EXPORT_TABLE_01" successfully completed at 05:55:56
OK,成功。
4.IMPDP的模糊匯入功能
1)生成一份包含所有表的備份檔案
ora10g@secDB /expdp$ expdp sec/sec directory=expdp_dir dumpfile=sec.dmp tables=%
2)清除sec使用者下的所有表
drop table TEST_SEC purge;
drop table TEST_SEC1 purge;
drop table TEST_SEC2 purge;
drop table T_SEC purge;
drop table T_SEC1 purge;
drop table T_SEC2 purge;
3)模糊匯入以“TEST”開頭的表
ora10g@secDB /expdp$ impdp sec/sec directory=expdp_dir dumpfile=sec.dmp tables=TEST%
Import: Release 10.2.0.3.0 - 64bit Production on Saturday, 09 April, 2010 6:08:41
Copyright (c) 2003, 2005, Oracle. All rights reserved.
Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bit Production
With the Partitioning, Oracle Label Security, OLAP and Data Mining Scoring Engine options
Master table "SEC"."SYS_IMPORT_TABLE_01" successfully loaded/unloaded
Starting "SEC"."SYS_IMPORT_TABLE_01": sec/******** directory=expdp_dir dumpfile=sec.dmp tables=TEST%
Processing object type TABLE_EXPORT/TABLE/TABLE
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
. . imported "SEC"."TEST_SEC" 1.018 MB 11716 rows
. . imported "SEC"."TEST_SEC1" 1.018 MB 11717 rows
. . imported "SEC"."TEST_SEC2" 1.018 MB 11718 rows
Job "SEC"."SYS_IMPORT_TABLE_01" successfully completed at 06:08:44
4)驗證匯入的資料
sys@ora10g> conn sec/sec
Connected.
sec@ora10g> select * from tab;
TNAME TABTYPE CLUSTERID
------------------------------ ------- ----------
TEST_SEC TABLE
TEST_SEC1 TABLE
TEST_SEC2 TABLE
OK,已經實現按需匯入。
5.小結
充分發掘既有工具的潛在功能是提高生命質量的前提保證。人類之所以偉大,就是因為我們會靈活使用各種優秀的工具:)
Good luck.
secooler
10.04.09
-- The End --
簡單演示,供參考。
注意萬用字元“_”含義。
1.環境準備
1)建立6張表,注意表名的規律。
sec@ora10g> create table TEST_SEC as select * from all_objects;
sec@ora10g> create table TEST_SEC1 as select * from all_objects;
sec@ora10g> create table TEST_SEC2 as select * from all_objects;
sec@ora10g> create table T_SEC as select * from all_objects;
sec@ora10g> create table T_SEC1 as select * from all_objects;
sec@ora10g> create table T_SEC2 as select * from all_objects;
2)檢視sec使用者下所有的表名
sec@ora10g> select * from tab;
TNAME TABTYPE CLUSTERID
------------------------------ ------- ----------
TEST_SEC TABLE
TEST_SEC2 TABLE
TEST_SEC1 TABLE
T_SEC TABLE
T_SEC1 TABLE
T_SEC2 TABLE
6 rows selected.
2.思考一下使用下面的模糊匯出後為什麼sec使用者下所有的表均被包含在內
ora10g@secDB /expdp$ expdp sec/sec directory=expdp_dir dumpfile=sec.dmp tables=T_S%
Export: Release 10.2.0.3.0 - 64bit Production on Saturday, 09 April, 2010 5:55:16
Copyright (c) 2003, 2005, Oracle. All rights reserved.
Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bit Production
With the Partitioning, Oracle Label Security, OLAP and Data Mining Scoring Engine options
Starting "SEC"."SYS_EXPORT_TABLE_01": sec/******** directory=expdp_dir dumpfile=sec.dmp tables=T_S%
Estimate in progress using BLOCKS method...
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 12 MB
Processing object type TABLE_EXPORT/TABLE/TABLE
Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
. . exported "SEC"."TEST_SEC" 1.013 MB 11678 rows
. . exported "SEC"."TEST_SEC1" 1.013 MB 11678 rows
. . exported "SEC"."TEST_SEC2" 1.013 MB 11678 rows
. . exported "SEC"."T_SEC" 1.013 MB 11678 rows
. . exported "SEC"."T_SEC1" 1.013 MB 11678 rows
. . exported "SEC"."T_SEC2" 1.013 MB 11678 rows
Master table "SEC"."SYS_EXPORT_TABLE_01" successfully loaded/unloaded
******************************************************************************
Dump file set for SEC.SYS_EXPORT_TABLE_01 is:
/expdp/sec.dmp
Job "SEC"."SYS_EXPORT_TABLE_01" successfully completed at 05:55:22
這裡是一個“美麗的誤會”,本意是想備份所有以“T_S”開頭的表,但是我們建立的6張表均被囊括在內了。根本原因是此處的下劃線“_”表示的是萬用字元!
3.僅備份以“TEST”開始的表
ora10g@secDB /expdp$ expdp sec/sec directory=expdp_dir dumpfile=sec.dmp tables=TEST%
Export: Release 10.2.0.3.0 - 64bit Production on Saturday, 09 April, 2010 5:55:51
Copyright (c) 2003, 2005, Oracle. All rights reserved.
Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bit Production
With the Partitioning, Oracle Label Security, OLAP and Data Mining Scoring Engine options
Starting "SEC"."SYS_EXPORT_TABLE_01": sec/******** directory=expdp_dir dumpfile=sec.dmp tables=TEST%
Estimate in progress using BLOCKS method...
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 6 MB
Processing object type TABLE_EXPORT/TABLE/TABLE
Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
. . exported "SEC"."TEST_SEC" 1.013 MB 11678 rows
. . exported "SEC"."TEST_SEC1" 1.013 MB 11678 rows
. . exported "SEC"."TEST_SEC2" 1.013 MB 11678 rows
Master table "SEC"."SYS_EXPORT_TABLE_01" successfully loaded/unloaded
******************************************************************************
Dump file set for SEC.SYS_EXPORT_TABLE_01 is:
/expdp/sec.dmp
Job "SEC"."SYS_EXPORT_TABLE_01" successfully completed at 05:55:56
OK,成功。
4.IMPDP的模糊匯入功能
1)生成一份包含所有表的備份檔案
ora10g@secDB /expdp$ expdp sec/sec directory=expdp_dir dumpfile=sec.dmp tables=%
2)清除sec使用者下的所有表
drop table TEST_SEC purge;
drop table TEST_SEC1 purge;
drop table TEST_SEC2 purge;
drop table T_SEC purge;
drop table T_SEC1 purge;
drop table T_SEC2 purge;
3)模糊匯入以“TEST”開頭的表
ora10g@secDB /expdp$ impdp sec/sec directory=expdp_dir dumpfile=sec.dmp tables=TEST%
Import: Release 10.2.0.3.0 - 64bit Production on Saturday, 09 April, 2010 6:08:41
Copyright (c) 2003, 2005, Oracle. All rights reserved.
Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bit Production
With the Partitioning, Oracle Label Security, OLAP and Data Mining Scoring Engine options
Master table "SEC"."SYS_IMPORT_TABLE_01" successfully loaded/unloaded
Starting "SEC"."SYS_IMPORT_TABLE_01": sec/******** directory=expdp_dir dumpfile=sec.dmp tables=TEST%
Processing object type TABLE_EXPORT/TABLE/TABLE
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
. . imported "SEC"."TEST_SEC" 1.018 MB 11716 rows
. . imported "SEC"."TEST_SEC1" 1.018 MB 11717 rows
. . imported "SEC"."TEST_SEC2" 1.018 MB 11718 rows
Job "SEC"."SYS_IMPORT_TABLE_01" successfully completed at 06:08:44
4)驗證匯入的資料
sys@ora10g> conn sec/sec
Connected.
sec@ora10g> select * from tab;
TNAME TABTYPE CLUSTERID
------------------------------ ------- ----------
TEST_SEC TABLE
TEST_SEC1 TABLE
TEST_SEC2 TABLE
OK,已經實現按需匯入。
5.小結
充分發掘既有工具的潛在功能是提高生命質量的前提保證。人類之所以偉大,就是因為我們會靈活使用各種優秀的工具:)
Good luck.
secooler
10.04.09
-- The End --
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/519536/viewspace-631778/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- oracle匯入匯出之expdp/impdpOracle
- expdp impdp只匯出匯入viewView
- expdp與impdp全庫匯出匯入
- Oracle資料泵匯出匯入(expdp/impdp)Oracle
- expdp與impdp全庫匯出匯入(二)
- Oracle 12c expdp和impdp匯出匯入表Oracle
- 資料庫泵(expdp/impdp)匯入匯出流程資料庫
- expdp impdp 資料庫匯入匯出命令詳解資料庫
- expdp/impdp中匯出/匯入任務的管理和監控
- Oracle使用資料泵expdp,impdp進行資料匯出匯入Oracle
- Oracle expdp/impdp匯出匯入命令及資料庫備份Oracle資料庫
- 通過EXPDP/IMPDP匯出匯入遠端資料倒本地
- Oracle expdp/impdp匯入匯出備份資料庫指令碼Oracle資料庫指令碼
- 使用EXPDP/IMPDP匯入匯出表中資料/後設資料測試
- EXPDP/IMPDP工具的使用
- Expdp,impdp工具的使用
- oracle 10.2.0.4 expdp全庫匯出 和分使用者impdp匯入的記錄Oracle
- 針對資料泵匯出 (expdp) 和匯入 (impdp)工具效能降低問題的檢查表
- oracle expdp和impdp使用例子Oracle
- 使用impdp network link 跳過expdp直接匯入資料
- Oracle 低版本匯入高版本按使用者expdp/impdpOracle
- 【impdp】使用impdp工具排除特定表的匯入
- impdp/expdp 示例
- oracle expdp and impdpOracle
- Oracle expdp/impdp 使用示例Oracle
- expdp/impdp 使用總結
- oracle10g expdp資料泵的bug,按schema匯出,匯入impdp時無jobOracle
- EXP COMPRESS以及EXP/IMP EXPDP/IMPDP匯入表結構注意
- expdp和impdp自動使用resumable特性
- impdp和expdp的總結
- expdp impdp 使用命令解析
- Expdp Impdp詳解
- oracle expdp/impdp用法Oracle
- impdp+network link 跳過expdp直接匯入目標庫
- 資料泵(expdp,impdp)高版本匯入低版本操作例項
- 【impdp】IMPDP中的TRANSFORM引數--【資料泵】EXPDP匯出表結構(真實案例)後傳ORM
- 資料泵IMPDP 匯入工具的使用
- EXPDP 和 IMPDP 資料泵的使用_1