Oracle 11g expdp中query参数的使用
发表于:2024-09-23 作者:千家信息网编辑
千家信息网最后更新 2024年09月23日,expdp中提供了query参数,可以在需要按条件导出表中部分数据时使用,它的使用就像是在select语句中的where条件使用一样。数据库版本zx@ORCL>select * from v$vers
千家信息网最后更新 2024年09月23日Oracle 11g expdp中query参数的使用
expdp中提供了query参数,可以在需要按条件导出表中部分数据时使用,它的使用就像是在select语句中的where条件使用一样。
数据库版本
zx@ORCL>select * from v$version;BANNER--------------------------------------------------------------------------------Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit ProductionPL/SQL Release 11.2.0.4.0 - ProductionCORE11.2.0.4.0ProductionTNS for Linux: Version 11.2.0.4.0 - ProductionNLSRTL Version 11.2.0.4.0 - Production
创建测试表
zx@ORCL>create table e1 (id number,name varchar2(20));Table created.zx@ORCL>create table e2 (id number,birthday date);Table created.
插入测试数据
zx@ORCL>insert into e1 select level,lpad(level,20,'*') from dual connect by level <= 100;100 rows created.zx@ORCL>commit;Commit complete.zx@ORCL>insert into e2 select level,sysdate-50+level from dual connect by level <= 100;100 rows created.zx@ORCL>commit;Commit complete.
创建目录
zx@ORCL>create directory dir as '/home/oracle/';Directory created.zx@ORCL>host
测试使用query导出
注意:如果query条件在parfile中则不需要用'\'进行转义
[oracle@rhel6 ~]$ expdp zx/zx directory=dir dumpfile=e1.dmp tables=zx.e1 query=zx.e1:\"where id<=50\"bash: =50": No such file or directoryExport: Release 11.2.0.4.0 - Production on Thu Jul 21 14:23:11 2016Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit ProductionWith the Partitioning, OLAP, Data Mining and Real Application Testing optionsStarting "ZX"."SYS_EXPORT_TABLE_01": zx/******** directory=dir dumpfile=e1.dmp tables=zx.e1 query=zx.e1:"where id<=50" Estimate in progress using BLOCKS method...Processing object type TABLE_EXPORT/TABLE/TABLE_DATATotal estimation using BLOCKS method: 64 KBProcessing object type TABLE_EXPORT/TABLE/TABLE. . exported "ZX"."E1" 6.757 KB 50 rowsMaster table "ZX"."SYS_EXPORT_TABLE_01" successfully loaded/unloaded******************************************************************************Dump file set for ZX.SYS_EXPORT_TABLE_01 is: /home/oracle/e1.dmpJob "ZX"."SYS_EXPORT_TABLE_01" successfully completed at Thu Jul 21 14:23:26 2016 elapsed 0 00:00:11exit
查询scn号
zx@ORCL>select dbms_flashback.get_system_change_number from dual;GET_SYSTEM_CHANGE_NUMBER------------------------ 2179047zx@ORCL>select count(*) from e1; COUNT(*)---------- 100
删除部分数据
zx@ORCL>delete from e1 where id<20;19 rows deleted.zx@ORCL>commit;Commit complete.zx@ORCL>host
测试query及flashback_scn
[oracle@rhel6 ~]$ expdp zx/zx directory=dir dumpfile=e1_1.dmp tables=zx.e1 query=zx.e1:\"where id\<=50\" flashback_scn=2179047Export: Release 11.2.0.4.0 - Production on Thu Jul 21 14:25:41 2016Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit ProductionWith the Partitioning, OLAP, Data Mining and Real Application Testing optionsStarting "ZX"."SYS_EXPORT_TABLE_01": zx/******** directory=dir dumpfile=e1_1.dmp tables=zx.e1 query=zx.e1:"where id<=50" flashback_scn=2179047 Estimate in progress using BLOCKS method...Processing object type TABLE_EXPORT/TABLE/TABLE_DATATotal estimation using BLOCKS method: 64 KBProcessing object type TABLE_EXPORT/TABLE/TABLE. . exported "ZX"."E1" 6.757 KB 50 rowsMaster table "ZX"."SYS_EXPORT_TABLE_01" successfully loaded/unloaded******************************************************************************Dump file set for ZX.SYS_EXPORT_TABLE_01 is: /home/oracle/e1_1.dmpJob "ZX"."SYS_EXPORT_TABLE_01" successfully completed at Thu Jul 21 14:25:49 2016 elapsed 0 00:00:06[oracle@rhel6 ~]$ exitexit
测试复杂query导出
zx@ORCL>select count(*) from e1 where id in( select id from e2 where birthdayhost
测试复杂query及flashback_scn导出
[oracle@rhel6 ~]$ expdp zx/zx directory=dir dumpfile=e1_3.dmp tables=zx.e1 query=zx.e1:\"where id in \( select id from e2 where birthday\删除e2部分数据
zx@ORCL>delete from e2 where id>25 and id<30;4 rows deleted.zx@ORCL>commit;Commit complete.zx@ORCL>select count(*) from e1 where id in( select id from e2 where birthday测试query及flashback_scn,结果只是对e1应用flashback_snc,e2没有应用
zx@ORCL>host[oracle@rhel6 ~]$ expdp zx/zx directory=dir dumpfile=e1_4.dmp tables=zx.e1 query=zx.e1:\"where id in \( select id from e2 where birthday\使e1和e2都应用flashback_scn
zx@ORCL>select count(*) from e1 where id in( select id from e2 as of scn 2179047 where birthdayhost[oracle@rhel6 ~]$ expdp zx/zx directory=dir dumpfile=e1_5.dmp tables=zx.e1 query=zx.e1:\"where id in \( select id from e2 as of scn 2179047 where birthday\ 多个表使用query条件则使用','分开
[oracle@rhel6 ~]$ expdp system/123456 directory=dump dumpfile=query.dmp tables=zx.abc,zx.abce query=zx.abc:\"where id \< 4\",zx.abce:\"where id \< 4\"Export: Release 11.2.0.4.0 - Production on Fri Dec 9 16:13:41 2016Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit ProductionWith the Partitioning, OLAP, Data Mining and Real Application Testing optionsFLASHBACK automatically enabled to preserve database integrity.Starting "SYSTEM"."SYS_EXPORT_TABLE_01": system/******** directory=dump dumpfile=query.dmp tables=zx.abc,zx.abce query=zx.abc:"where id < 4",zx.abce:"where id < 4" Estimate in progress using BLOCKS method...Processing object type TABLE_EXPORT/TABLE/TABLE_DATATotal estimation using BLOCKS method: 384 KBProcessing object type TABLE_EXPORT/TABLE/TABLE. . exported "ZX"."ABC" 5.898 KB 2 rows. . exported "ZX"."ABCE" 5.898 KB 2 rowsMaster table "SYSTEM"."SYS_EXPORT_TABLE_01" successfully loaded/unloaded******************************************************************************Dump file set for SYSTEM.SYS_EXPORT_TABLE_01 is: /home/oracle/query.dmpJob "SYSTEM"."SYS_EXPORT_TABLE_01" successfully completed at Fri Dec 9 16:14:04 2016 elapsed 0 00:00:19
测试
数据
条件
应用
复杂
部分
参数
只是
多个
数据库
是在
版本
目录
结果
语句
转义
查询
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
软件开发技术风险及对策
科技网 互联网电视
网络安全与执法的体检要求
八万块钱服务器
陕西华山服务器
怎么查看数据库字符集
dapper 达梦数据库
网络安全段国云
快门网络技术有限公司加班
关系数据库模型的数据完整性
灌南口碑好的网络技术排名靠前
百度软件开发商场
网络安全宣传周主题宣传标语
光斑分析仪软件开发
浪潮服务器功率一台多少kw
网站文件服务器
计算机网络技术高级工
重庆服务器阵列恢复
计算机网络技术专修课程
广州指猴互联网科技
陇南市网络安全培训机构
浦东新区数据软件开发报价表
畅连服务器
浪潮服务器在国内市场
U8盘点单的数据库表名
简单的数据库设计逻辑
学校很差的人学软件开发
数据库1146错误什么意思
普通人要怎么预防网络安全
校园网络安全周讲话稿