exp query条件导出 研究_MySQL, Oracle及数据库讨论区_Weblogic技术|Tuxedo技术|中间件技术|Oracle论坛|JAVA论坛|Linux/Unix技术|hadoop论坛_联动北方技术论坛  
网站首页 | 关于我们 | 服务中心 | 经验交流 | 公司荣誉 | 成功案例 | 合作伙伴 | 联系我们 |
联动北方-国内领先的云技术服务提供商
»  游客             当前位置:  论坛首页 »  自由讨论区 »  MySQL, Oracle及数据库讨论区 »
总帖数
1
每页帖数
101/1页1
返回列表
0
发起投票  发起投票 发新帖子
查看: 2054 | 回复: 0   主题: exp query条件导出 研究        下一篇 
masy
注册用户
等级:少校
经验:1234
发帖:182
精华:0
注册:2011-11-4
状态:离线
发送短消息息给masy 加好友    发送短消息息给masy 发消息
发表于: IP:您无权察看 2015-4-8 17:46:43 | [全部帖] [楼主帖] 楼主

--从生产导数据时发现ods库不能用expdp,于是想试一下exp方法
--但发现也不行。不过研究了一下exp的条件导出语句
--exp不同于expdp,相对来说功能没expdp强大
--对于条件导出,exp相比expdp,不能进行多表多条件的导出,只能进行单个条件的限制
--实例语句:
exp scott/tiger TABLES=(emp,bonus) QUERY=\"WHERE job=\'SALESMAN\' and sal\<1600\"
--推荐使用parfile文件进行exp导出,在parfile文件中query可以直接写成
QUERY="WHERE job='SALESMAN' and sal<1600"
--而不需要进行字符的转义
--另外exp的条件导出有一些限制:
1.The parameter QUERY cannot be specified for full, user, or tablespace mode exports.


参数query不能使用在完全导出,用户导出和表空间导出方式

2.The parameter QUERY must be applicable to all specified tables. 

参数query指定的内容必须对所有指定的表都有效

3.The parameter QUERY cannot be specified in a direct path export (DIRECT=y) 

参数query不能与direct路径导出同时使用,因为direct是直接路径读取数据文件导出,而使用了条件语句就必须走sql方法导出了

所以不能同时使用

4.The parameter QUERY cannot be specified for tables with inner nested tables. 

参数query不能导出内嵌表

5.You cannot determine from the contents of the export file whether the data is the result of a QUERY export. 

用query参数导出的数据与同其他方式导出的数据是一样的,无法根据导出文件进行分辨

--实验
--实验环境:本地linux虚拟机,Oracle数据库版本11gR2
--创建相关测试表
create table scott.exp_obj as select * from dba_objects;
create table scott.exp_tab as select * from dba_tables;
--1、exp条件导出
[oracle@localhost ~]$ cd /home/software
[oracle@localhost exp_dir]$ vi exp_test1.par
userid='/ as sysdba'
file=exp_test1.dmp
tables=(scott.exp_obj,scott.exp_tab)
query="where owner='SCOTT'"
log=exp_test1.log
[oracle@localhost exp_dir]$exp parfile=exp_test1.par
--结果:成功导出部分数据
About to export specified tables via Conventional Path ...
Current user changed to SCOTT
. . exporting table      EXP_OBJ     19 rows exported
. . exporting table      EXP_TAB     8 rows exported
Export terminated successfully without warnings.
--2、exp条件不是对所有表都适用的情况
[oracle@localhost exp_dir]$ vi exp_test2.par
userid='/ as sysdba'
file=exp_test2.dmp
tables=(scott.exp_obj,scott.exp_tab)
query="where owner='SCOTT' and table_name is not null"
log=exp_test2.log
[oracle@localhost exp_dir]$exp parfile=exp_test2.par
--结果:不适用约束的表导出报错,适用约束的表导出成功
About to export specified tables via Conventional Path ...
Current user changed to SCOTT
. . exporting table      EXP_OBJ
EXP-00056: ORACLE error 904 encountered
ORA-00904: "TABLE_NAME": invalid identifier
. . exporting table      EXP_TAB    8 rows exported
Export terminated successfully with warnings.
--3、exp条件导出与direct路径同时使用
[oracle@localhost ~]$ cd /home/software
[oracle@localhost exp_dir]$ vi exp_test3.par
userid='/ as sysdba'
file=exp_test3.dmp
tables=(scott.exp_obj,scott.exp_tab)
query="where owner='SCOTT'"
direct=y
log=exp_test3.log
[oracle@localhost exp_dir]$exp parfile=exp_test3.par
--结果:报错,导出失败,无法query导出和direct路径同时使用
Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
EXP-00071: QUERY parameter not compatible with Direct Path export
EXP-00000: Export terminated unsuccessfully


--转自 北京联动北方科技有限公司




赞(0)    操作        顶端 
总帖数
1
每页帖数
101/1页1
返回列表
发新帖子
请输入验证码: 点击刷新验证码
您需要登录后才可以回帖 登录 | 注册
技术讨论