ORACLE 資料泵之NETWORK_LINK
資料泵之NETWORK_LINK
blog結構圖:
1 環境介紹
|
SOURCE DB(虛擬機器) |
TARGET DB(虛擬機器) |
CLIENT(筆記本) |
EXP/IMP |
11.2.0.3.0 |
11.2.0.1.0 |
11.2.0.1.0 |
EXPDP/IMPDP |
11.2.0.3.0 |
11.2.0.1.0 |
11.2.0.1.0 |
HOST IP |
192.168.59.130 |
192.168.59.128 |
192.168.59.1 |
host 平臺 記憶體 |
RHEL 6.5 MemTotal: 2.6g |
windows XP MemTotal: 2g |
windows 8.1 MemTotal: 20g |
DB VERSION |
11.2.0.3.0 |
11.2.0.1.0 |
無 |
ORACLE_SID |
orclasm |
orcl |
無 |
tnsname |
orclasm |
orclxp |
|
注意: 本實驗所有的程式碼無特殊說明均在client客戶端執行
圖形關係如下:
2 imp和exp簡介
首先來看這句話: expdp屬於服務端工具,而exp屬於客戶端工具,expdp生成的檔案預設是存放在服務端的,而exp生成的檔案是存放在客戶端的
來驗證exp和imp:
我們在client客戶端執行:
C:\Users\Administrator>exp lhr/lhr@orclasm tables=xb_log_lhr file=e:\e1.dmp log=E:\exp_table.log buffer=41943040
Export: Release 11.2.0.1.0 - Production on 星期二 2月 10 15:55:25 2015
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
連線到: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, Automatic Storage Management, OLAP, Data Mining
and Real Application Testing options
已匯出 ZHS16GBK 字符集和 AL16UTF16 NCHAR 字符集
即將匯出指定的表通過常規路徑...
. . 正在匯出表 XB_LOG_LHR匯出了 56 行
成功終止匯出, 沒有出現警告。
C:\Users\Administrator>imp lhr/lhr@orclxp tables=xb_log_lhr file=e:\e1.dmp log=E:\exp_table.log buffer=41943040
Import: Release 11.2.0.1.0 - Production on 星期二 2月 10 15:59:42 2015
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
連線到: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
經由常規路徑由 EXPORT:V11.02.00 建立的匯出檔案
已經完成 ZHS16GBK 字符集和 AL16UTF16 NCHAR 字符集中的匯入
. 正在將 LHR 的物件匯入到 LHR
. 正在將 LHR 的物件匯入到 LHR
. . 正在匯入表 "XB_LOG_LHR"匯入了 56 行
成功終止匯入, 沒有出現警告。
而檔案也的確是在本機的:
3 expdp不使用network_link
根據expdp的語法,我們執行如下指令碼:
C:\Users\Administrator>expdp lhr/lhr@orclasm directory=DATA_PUMP_DIR dumpfile=exptable.dmp TABLES=xb_log_lhr LOGFILE=expdp_table.log
Export: Release 11.2.0.1.0 - Production on 星期二 2月 10 16:37:40 2015
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
連線到: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, Automatic Storage Management, OLAP, Data Mining
and Real Application Testing options
啟動 "LHR"."SYS_EXPORT_TABLE_01": lhr/********@orclasm directory=DATA_PUMP_DIR dumpfile=exptable.dmp TABLES=xb_log_lhr LOGFILE=expdp_table.log
正在使用 BLOCKS 方法進行估計...
處理物件型別 TABLE_EXPORT/TABLE/TABLE_DATA
使用 BLOCKS 方法的總估計: 64 KB
處理物件型別 TABLE_EXPORT/TABLE/TABLE
處理物件型別 TABLE_EXPORT/TABLE/COMMENT
處理物件型別 TABLE_EXPORT/TABLE/INDEX/INDEX
處理物件型別 TABLE_EXPORT/TABLE/INDEX/FUNCTIONAL_INDEX/INDEX
處理物件型別 TABLE_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
處理物件型別 TABLE_EXPORT/TABLE/INDEX/STATISTICS/FUNCTIONAL_INDEX/INDEX_STATISTICS
處理物件型別 TABLE_EXPORT/TABLE/TRIGGER
處理物件型別 TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
. . 匯出了 "LHR"."XB_LOG_LHR" 18.75 KB 56 行
已成功載入/解除安裝了主表 "LHR"."SYS_EXPORT_TABLE_01"
******************************************************************************
LHR.SYS_EXPORT_TABLE_01 的轉儲檔案集為:
/u01/app/oracle/admin/orclasm/dpdump/exptable.dmp
作業 "LHR"."SYS_EXPORT_TABLE_01" 已於 16:38:00 成功完成
C:\Users\Administrator>
在伺服器端檢視可知,檔案是存放在linux伺服器端的:
[oracle@rhel6_lhr dpdump]$ ll
total 156
-rw-r--r-- 1 oracle asmadmin 1391 Feb 10 16:38 expdp_table.log
-rw-r----- 1 oracle asmadmin 151552 Feb 10 16:38 exptable.dmp
[oracle@rhel6_lhr dpdump]$ pwd
/u01/app/oracle/admin/orclasm/dpdump
[oracle@rhel6_lhr dpdump]$
而在這種情況下必須將exptable.dmp 拷貝到windows XP上的相應目錄下才能使用impdp來進行匯入,如下利用ftp下載:
將exptable.dmp放到windows XP下的虛擬機器裡:
C:\Users\Administrator>sqlplus lhr/lhr@orclxp
SQL*Plus: Release 11.2.0.1.0 Production on 星期二 2月 10 16:46:37 2015
Copyright (c) 1982, 2010, Oracle. All rights reserved.
連線到:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> set line 9999
SQL> SELECT * FROM dba_directories d WHERE d.directory_name='DATA_PUMP_DIR';
OWNER DIRECTORY_NAME DIRECTORY_PATH
------------------------------ ------------------------------ ---------------------------------------------------------------------
SYS DATA_PUMP_DIR F:\app\oracle\admin\orcl\dpdump\
SQL>
然後再進行匯入操作:
C:\Users\Administrator>impdp lhr/lhr@orclxp directory=DATA_PUMP_DIR dumpfile=exptable.dmp LOGFILE=impdp_table.log
Import: Release 11.2.0.1.0 - Production on 星期二 2月 10 16:50:46 2015
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
連線到: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
已成功載入/解除安裝了主表 "LHR"."SYS_IMPORT_FULL_01"
啟動 "LHR"."SYS_IMPORT_FULL_01": lhr/********@orclxp directory=DATA_PUMP_DIR dumpfile=exptable.dmp LOGFILE=impdp_table.log
處理物件型別 TABLE_EXPORT/TABLE/TABLE
處理物件型別 TABLE_EXPORT/TABLE/TABLE_DATA
. . 匯入了 "LHR"."XB_LOG_LHR" 18.75 KB 56 行
處理物件型別 TABLE_EXPORT/TABLE/COMMENT
處理物件型別 TABLE_EXPORT/TABLE/INDEX/INDEX
處理物件型別 TABLE_EXPORT/TABLE/INDEX/FUNCTIONAL_INDEX/INDEX
處理物件型別 TABLE_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
處理物件型別 TABLE_EXPORT/TABLE/INDEX/STATISTICS/FUNCTIONAL_INDEX/INDEX_STATISTICS
處理物件型別 TABLE_EXPORT/TABLE/TRIGGER
處理物件型別 TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
作業 "LHR"."SYS_IMPORT_FULL_01" 已經完成。
C:\Users\Administrator>
日誌檔案路徑:
這樣操作是否非常麻煩,那麼如何將生成的檔案放在目標資料庫而不放在源資料庫呢,在expdp中使用network_link。
4 expdp使用network_link
4.1 目標資料庫建立dblink
C:\Users\Administrator>sqlplus lhr/lhr@orclxp
SQL*Plus: Release 11.2.0.1.0 Production on 星期二 2月 10 16:55:43 2015
Copyright (c) 1982, 2010, Oracle. All rights reserved.
連線到:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> create public database link dblk_orclasm connect to lhr identified by lhr using 'orclasm' ;
資料庫連結已建立。
SQL> SELECT count(1) FROM xb_log_lhr@dblk_orclasm;
COUNT(1)
----------
56
SQL> SELECT count(1) FROM xb_log_lhr;
SELECT count(1) FROM xb_log_lhr
*
第 1 行出現錯誤:
ORA-00942: 表或檢視不存在
SQL>
SQL> exit
從 Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options 斷開
C:\Users\Administrator>
4.2 client端或目標資料庫執行
注意這裡的連線識別符號是orclxp,即連線到windows xp系統,是target庫。
C:\Users\Administrator>expdp lhr/lhr@orclxp directory=DATA_PUMP_DIR dumpfile=exptable.dmp TABLES=xb_log_lhr network_link=dblk_orclasm LOGFILE=expdp_table.log
Export: Release 11.2.0.1.0 - Production on 星期二 2月 10 17:07:35 2015
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
連線到: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
啟動 "LHR"."SYS_EXPORT_TABLE_01": lhr/********@orclxp directory=DATA_PUMP_DIR dumpfile=exptable.dmp TABLES=xb_log_lhr network_link=dblk_orclasm LOGFILE=expdp_table.log
正在使用 BLOCKS 方法進行估計...
處理物件型別 TABLE_EXPORT/TABLE/TABLE_DATA
使用 BLOCKS 方法的總估計: 64 KB
處理物件型別 TABLE_EXPORT/TABLE/TABLE
處理物件型別 TABLE_EXPORT/TABLE/COMMENT
處理物件型別 TABLE_EXPORT/TABLE/INDEX/INDEX
處理物件型別 TABLE_EXPORT/TABLE/INDEX/FUNCTIONAL_INDEX/INDEX
處理物件型別 TABLE_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
處理物件型別 TABLE_EXPORT/TABLE/INDEX/STATISTICS/FUNCTIONAL_INDEX/INDEX_STATISTICS
處理物件型別 TABLE_EXPORT/TABLE/TRIGGER
處理物件型別 TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
. . 匯出了 "LHR"."XB_LOG_LHR" 18.75 KB 56 行
已成功載入/解除安裝了主表 "LHR"."SYS_EXPORT_TABLE_01"
******************************************************************************
LHR.SYS_EXPORT_TABLE_01 的轉儲檔案集為:
F:\APP\ORACLE\ADMIN\ORCL\DPDUMP\EXPTABLE.DMP
作業 "LHR"."SYS_EXPORT_TABLE_01" 已於 17:07:58 成功完成
C:\Users\Administrator>
結果:
C:\Users\Administrator>impdp lhr/lhr@orclxp directory=DATA_PUMP_DIR dumpfile=exptable.dmp LOGFILE=impdp_table.log
Import: Release 11.2.0.1.0 - Production on 星期二 2月 10 17:13:20 2015
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
連線到: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
已成功載入/解除安裝了主表 "LHR"."SYS_IMPORT_FULL_01"
啟動 "LHR"."SYS_IMPORT_FULL_01": lhr/********@orclxp directory=DATA_PUMP_DIR dumpfile=exptable.dmp LOGFILE=impdp_table.log
處理物件型別 TABLE_EXPORT/TABLE/TABLE
處理物件型別 TABLE_EXPORT/TABLE/TABLE_DATA
. . 匯入了 "LHR"."XB_LOG_LHR" 18.75 KB 56 行
處理物件型別 TABLE_EXPORT/TABLE/COMMENT
處理物件型別 TABLE_EXPORT/TABLE/INDEX/INDEX
處理物件型別 TABLE_EXPORT/TABLE/INDEX/FUNCTIONAL_INDEX/INDEX
處理物件型別 TABLE_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
處理物件型別 TABLE_EXPORT/TABLE/INDEX/STATISTICS/FUNCTIONAL_INDEX/INDEX_STATISTICS
處理物件型別 TABLE_EXPORT/TABLE/TRIGGER
處理物件型別 TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
作業 "LHR"."SYS_IMPORT_FULL_01" 已經完成(於 17:13:23 完成)
C:\Users\Administrator>
4.3 總結
採用network_link選項時,所有的操作均在target即目標端執行。
5 impdp使用network_link
如果想不生成dmp檔案而直接將需要的資料匯入garget資料庫,則直接使用impdp帶network_link ,這樣可以直接impdp,而繞過了expdp的步驟
5.1 目標資料庫建立dblink
C:\Users\Administrator>sqlplus lhr/lhr@orclxp
SQL*Plus: Release 11.2.0.1.0 Production on 星期二 2月 10 16:55:43 2015
Copyright (c) 1982, 2010, Oracle. All rights reserved.
連線到:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> create public database link dblk_orclasm connect to lhr identified by lhr using 'orclasm' ;
資料庫連結已建立。
SQL> SELECT count(1) FROM xb_log_lhr@dblk_orclasm;
COUNT(1)
----------
56
SQL> SELECT count(1) FROM xb_log_lhr;
SELECT count(1) FROM xb_log_lhr
*
第 1 行出現錯誤:
ORA-00942: 表或檢視不存在
SQL>
SQL> exit
從 Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options 斷開
C:\Users\Administrator>
.5.2 client或目標端執行
C:\Users\Administrator>impdp lhr/lhr@orclxp network_link=dblk_orclasm directory=DATA_PUMP_DIR TABLES=xb_log_lhr PARALLEL=2
Import: Release 11.2.0.1.0 - Production on 星期二 2月 10 17:20:58 2015
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
連線到: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
啟動 "LHR"."SYS_IMPORT_TABLE_01": lhr/********@orclxp network_link=dblk_orclasm directory=DATA_PUMP_DIR TABLES=xb_log_lhr PARALLEL=2
正在使用 BLOCKS 方法進行估計...
處理物件型別 TABLE_EXPORT/TABLE/TABLE_DATA
使用 BLOCKS 方法的總估計: 64 KB
處理物件型別 TABLE_EXPORT/TABLE/TABLE
. . 匯入了 "LHR"."XB_LOG_LHR" 56 行
處理物件型別 TABLE_EXPORT/TABLE/COMMENT
處理物件型別 TABLE_EXPORT/TABLE/INDEX/INDEX
處理物件型別 TABLE_EXPORT/TABLE/INDEX/FUNCTIONAL_INDEX/INDEX
處理物件型別 TABLE_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
處理物件型別 TABLE_EXPORT/TABLE/INDEX/STATISTICS/FUNCTIONAL_INDEX/INDEX_STATISTICS
處理物件型別 TABLE_EXPORT/TABLE/TRIGGER
處理物件型別 TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
作業 "LHR"."SYS_IMPORT_TABLE_01" 已經完成(於 17:21:10 完成)
C:\Users\Administrator>
5.3 總結
不生成資料檔案而直徑匯入的方法類似於在目標庫中執行create table xxx as select * from xxx@dblink ,不過impdp+nework_link一併將資料及其索引觸發器等都匯入到了目標端,這樣就省了很多事情了。
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/26736162/viewspace-1432591/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- oracle之資料泵Oracle
- 11g資料泵NETWORK_LINK功能增強
- ORACLE 資料泵Oracle
- oracle資料泵Oracle
- oracle邏輯備份之--資料泵Oracle
- oracle 資料泵解析Oracle
- Oracle 資料泵的使用Oracle
- oracle 資料泵引數Oracle
- 資料庫升級之-資料泵資料庫
- 使用network_link複製Oracle資料庫Oracle資料庫
- oracle資料泵備份(Expdp命令)Oracle
- Oracle資料庫(資料泵)遷移方案(上)Oracle資料庫
- Oracle資料庫(資料泵)遷移方案(下)Oracle資料庫
- Oracle資料泵(Oracle Data Pump) 19cOracle
- 資料庫遷移之資料泵實驗資料庫
- oracle之 資料泵dump檔案存放nfs報ORA-27054OracleNFS
- oracle10G新特性之資料泵匯出/匯入Oracle
- 資料泵
- Oracle expdp資料泵遠端匯出Oracle
- 使用Oracle資料泵問題總結Oracle
- Oracle資料泵-schema匯入匯出Oracle
- Oracle備份恢復五(資料泵)Oracle
- oracle11g資料泵詳解Oracle
- 詳說Oracle Vault——使用資料泵工具Oracle
- oracle 資料泵 content=data_onlyOracle
- 轉oracle資料泵匯出時報錯Oracle
- Oracle使用impdp的network_link遷移資料庫Oracle資料庫
- Oracle使用資料泵在異機之間匯出匯入表Oracle
- 【12C】Oracle 12c 可插拔資料庫之資料泵功能體驗Oracle資料庫
- 【ASK_ORACLE】重灌Oracle資料泵(Datapump)工具的方法Oracle
- 史上最全Oracle資料泵常用命令Oracle
- Oracle Data Pump 11G 資料泵元件Oracle元件
- Oracle資料泵的匯入和匯出Oracle
- Oracle資料泵匯出匯入(expdp/impdp)Oracle
- Oracle資料泵的備份與恢復Oracle
- Oracle使用資料泵匯出匯入表Oracle
- ORACLE 10g資料泵使用說明Oracle 10g
- Oracle network_linkOracle