Oracle expdp數據泵遠程導出
鏈接:http://blog.itpub.net/28602568/viewspace-759524/
標題: Oracle expdp數據泵遠程導出
作者:lōττéry©版權所有[文章允許轉載,但必須以鏈接方式注明源地址,否則追究法律責任.]
expdp數據泵
優點:支持并發多線程方式,可以遠程導出,性能顯著提高,可開并行parallel=n,比exp/imp實用工具相比,導出提高了10倍左右,導入提高了5倍左右。能根據備份時收集的元數據,自動創建用戶、表對象,支持作業、表空間備份方式。
缺點:需要在服務器上面執行創建目錄授權, expdp、exp都支持遠程本地導出 。
(exp不支持字段類型,BINARY_DOUBLE雙精度二進制浮點類型 http://www.2cto.com/database/201202/119920.html number類型和浮點類型區別“number 十進制,BINARY_DOUBLE二進制(比number效率高,速度快,占用空間小的優點.但版本兼容性不好)”)
(expdp不支持網絡鏈來加載long"保存文本類型"列,exp支持long的導出導入)
當出現”DB所在空間不足需要跨機器導出備份/恢復"時,需要用到expdp的遠程導出,實現:只要在本地數據庫 執行創建public link和dir及給對應的權限就可以將遠程DB導出到本地路徑。
具體實驗如下,所有操作都在本地
SQL> create user test identified by test;
SQL> grant dba to test;
-->創建目錄
SQL> create directory dump_dir AS 'E:\dump_dir';
SQL> select DIRECTORY_NAME,DIRECTORY_PATH from dba_directories where directory_name='DUMP_DIR';
OWNER DIRECTORY_NAME DIRECTORY_PATH
-----------------------------------------------------------------------------------------------------------------------------------------------------
SYS DUMP_DIR E:\dump_dir
-->創建DBLINK
SQL> create public database link kfdb7 connect to 用戶 identified by "密碼" using '(DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = XX.XX.XX.XX)(PORT = 1521端口號))) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = SID ) ) )';
-->驗證dblink 有效性
SQL> conn test/test
已連接。
SQL> select * from tab;
未選定行
SQL> select count(*) from base_dict@kfdb57;
COUNT(*)
----------
683
****注意:要創建public database link 如果只創建 database link 只能再當前用戶下訪問鏈接庫數據,但導出來報錯
ORA-39001: 參數值無效
ORA-39200: 鏈接名稱 "kfdb5" 無效。
ORA-02019: 未找到遠程數據庫的連接說明
具體解釋:
Use the CREATE DATABASE LINK statement to create a database link. A database link is a schema object in one database that enables you to access objects on another database. The other database need not be an Oracle Database system. However, to access non-Oracle systems you must use Oracle Heterogeneous Services.
After you have created a database link, you can use it to refer to tables and views on the other database. In SQL statements, you can refer to a table or view on the other database by appending @dblink to the table or view name. You can query a table or view on the other database with the SELECT statement. You can also access remote tables and views using any INSERT, UPDATE, DELETE, or LOCK TABLE statement.
To create a private database link, you must have the CREATE DATABASE LINK system privilege. To create a public database link, you must have the CREATE PUBLIC DATABASE LINK system privilege. Also, you must have the CREATE SESSION system privilege on the remote Oracle database. Oracle Net must be installed on both the local and remote Oracle databases.
導出命令:
E:\oracle\product\10.2.0\db_1\BIN>EXPDP.EXE test/test network_link=kfdb57 directory=DUMP_DIR1 dumpfile=base_dict.dmp tables='base_dict'
Export: Release 10.2.0.1.0 - Production on 星期一, 11 3月, 2013 17:51:56
Copyright (c) 2003, 2005, Oracle. All rights reserved.
連接到: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
啟動 "TEST"."SYS_EXPORT_TABLE_01": test/******** network_link=kfdb57 directory=DUMP_DIR1 dumpfile=base_dict.dmp tables='base_dict'
正在使用 BLOCKS 方法進行估計...
處理對象類型 TABLE_EXPORT/TABLE/TABLE_DATA
使用 BLOCKS 方法的總估計: 64 KB
處理對象類型 TABLE_EXPORT/TABLE/TABLE
處理對象類型 TABLE_EXPORT/TABLE/INDEX/INDEX
處理對象類型 TABLE_EXPORT/TABLE/CONSTRAINT/CONSTRAINT
處理對象類型 TABLE_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
處理對象類型 TABLE_EXPORT/TABLE/COMMENT
處理對象類型 TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
. . 導出了 "SINOSOFT"."BASE_DICT" 35.73 KB 683 行
已成功加載/卸載了主表 "TEST"."SYS_EXPORT_TABLE_01"
******************************************************************************
TEST.SYS_EXPORT_TABLE_01 的轉儲文件集為: E:\DUMP_DIR\BASE_DICT.DMP
作業 "TEST"."SYS_EXPORT_TABLE_01" 已于 17:54:09 成功完成
擴展:
將導出得文件導入到本地數據庫命令:impdp.exe test/test directory=dump_dir1 dumpfile=base_dict.dmp tables=base_dict REMAP_SCHEMA=sinosoft:test
查看導入情況:
SQL> select * from tab;
TNAME TABTYPE CLUSTERID
------------------------------ ------- ----------
SYS_IMPORT_TABLE_01 TABLE
SQL> select * from tab;
TNAME TABTYPE CLUSTERID
------------------------------ ------- ----------
SYS_IMPORT_TABLE_01 TABLE -->主表 在完成后數據庫會自動刪除主表(導出失敗則否)
BASE_DICT TABLE
SQL> select * from tab;
TNAME TABTYPE CLUSTERID
------------------------------ ------- ----------
BASE_DICT TABLE
SQL> select count(*) from base_dict;
COUNT(*)
----------
683
測試完畢后刪除dblink+ directory
drop directory dump_dir ;
drop public database link kfdb57;
擴展: 研究 - IMPDP [TRANSFORM=segment_attributes:n] [remap_tablespace] 2參數間影響關系 -->用于impdp+dblink有無默認表空間的數據存放到表空間的情況。
【源于本人筆記】 若有書寫錯誤,表達錯誤,請指正...
此條目發表在 EXP[DP]/IMP[DP] 分類目錄。將固定連接加入收藏夾。