链接: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] 分类目录。将固定连接加入收藏夹。