iis服务器助手广告广告
返回顶部
首页 > 资讯 > 数据库 >Oracle 11g expdp中query参数的使用
  • 949
分享到

Oracle 11g expdp中query参数的使用

2024-04-02 19:04:59 949人浏览 薄情痞子
摘要

expdp中提供了query参数,可以在需要按条件导出表中部分数据时使用,它的使用就像是在select语句中的where条件使用一样。数据库版本zx@ORCL>select&nbs

expdp中提供了query参数,可以在需要按条件导出表中部分数据时使用,它的使用就像是在select语句中的where条件使用一样。

数据库版本

zx@ORCL>select * from v$version;
BANNER
--------------------------------------------------------------------------------
oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
PL/sql Release 11.2.0.4.0 - Production
CORE11.2.0.4.0Production
TNS for linux: Version 11.2.0.4.0 - Production
NLSRTL 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 directory
Export: Release 11.2.0.4.0 - Production on Thu Jul 21 14:23:11 2016
Copyright (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 Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Starting "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_DATA
Total estimation using BLOCKS method: 64 KB
Processing object type TABLE_EXPORT/TABLE/TABLE
. . exported "ZX"."E1"                                   6.757 KB      50 rows
Master table "ZX"."SYS_EXPORT_TABLE_01" successfully loaded/unloaded
******************************************************************************
Dump file set for ZX.SYS_EXPORT_TABLE_01 is:
  /home/oracle/e1.dmp
Job "ZX"."SYS_EXPORT_TABLE_01" successfully completed at Thu Jul 21 14:23:26 2016 elapsed 0 00:00:11
exit

查询scn号

zx@ORCL>select dbms_flashback.get_system_change_number from dual;
GET_SYSTEM_CHANGE_NUMBER
------------------------
 2179047
zx@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=2179047
Export: Release 11.2.0.4.0 - Production on Thu Jul 21 14:25:41 2016
Copyright (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 Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Starting "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_DATA
Total estimation using BLOCKS method: 64 KB
Processing object type TABLE_EXPORT/TABLE/TABLE
. . exported "ZX"."E1"                                   6.757 KB      50 rows
Master table "ZX"."SYS_EXPORT_TABLE_01" successfully loaded/unloaded
******************************************************************************
Dump file set for ZX.SYS_EXPORT_TABLE_01 is:
  /home/oracle/e1_1.dmp
Job "ZX"."SYS_EXPORT_TABLE_01" successfully completed at Thu Jul 21 14:25:49 2016 elapsed 0 00:00:06
[oracle@rhel6 ~]$ exit
exit

测试复杂query导出

zx@ORCL>select count(*) from e1 where id in( select id from e2 where birthday<sysdate);
  COUNT(*)
----------
31
[oracle@rhel6 ~]$ expdp zx/zx directory=dir dumpfile=e1_2.dmp tables=zx.e1 query=zx.e1:\"where id in \( select id from e2 where birthday\<sysdate\)\" 
Export: Release 11.2.0.4.0 - Production on Thu Jul 21 14:31:04 2016
Copyright (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 Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Starting "ZX"."SYS_EXPORT_TABLE_01":  zx/******** directory=dir dumpfile=e1_2.dmp tables=zx.e1 query=zx.e1:"where id in ( select id from e2 where birthday<sysdate)" 
Estimate in progress using BLOCKS method...
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 64 KB
Processing object type TABLE_EXPORT/TABLE/TABLE
. . exported "ZX"."E1"                                   6.242 KB      31 rows
Master table "ZX"."SYS_EXPORT_TABLE_01" successfully loaded/unloaded
******************************************************************************
Dump file set for ZX.SYS_EXPORT_TABLE_01 is:
  /home/oracle/e1_2.dmp
Job "ZX"."SYS_EXPORT_TABLE_01" successfully completed at Thu Jul 21 14:31:12 2016 elapsed 0 00:00:06
[oracle@rhel6 ~]$ exit
exit
zx@ORCL>host

测试复杂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\<sysdate\)\"  flashback_scn=2179047
Export: Release 11.2.0.4.0 - Production on Thu Jul 21 14:32:07 2016
Copyright (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 Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Starting "ZX"."SYS_EXPORT_TABLE_01":  zx/******** directory=dir dumpfile=e1_3.dmp tables=zx.e1 query=zx.e1:"where id in ( select id from e2 where birthday<sysdate)" flashback_scn=2179047 
Estimate in progress using BLOCKS method...
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 64 KB
Processing object type TABLE_EXPORT/TABLE/TABLE
. . exported "ZX"."E1"                                   6.757 KB      50 rows
Master table "ZX"."SYS_EXPORT_TABLE_01" successfully loaded/unloaded
******************************************************************************
Dump file set for ZX.SYS_EXPORT_TABLE_01 is:
  /home/oracle/e1_3.dmp
Job "ZX"."SYS_EXPORT_TABLE_01" successfully completed at Thu Jul 21 14:32:14 2016 elapsed 0 00:00:06
[oracle@rhel6 ~]$ exit
exit

删除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<sysdate);
  COUNT(*)
----------
27

测试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\<sysdate\)\"  flashback_scn=2179047
Export: Release 11.2.0.4.0 - Production on Thu Jul 21 14:33:55 2016
Copyright (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 Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Starting "ZX"."SYS_EXPORT_TABLE_01":  zx/******** directory=dir dumpfile=e1_4.dmp tables=zx.e1 query=zx.e1:"where id in ( select id from e2 where birthday<sysdate)" flashback_scn=2179047 
Estimate in progress using BLOCKS method...
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 64 KB
Processing object type TABLE_EXPORT/TABLE/TABLE
. . exported "ZX"."E1"                                   6.648 KB      46 rows
Master table "ZX"."SYS_EXPORT_TABLE_01" successfully loaded/unloaded
******************************************************************************
Dump file set for ZX.SYS_EXPORT_TABLE_01 is:
  /home/oracle/e1_4.dmp
Job "ZX"."SYS_EXPORT_TABLE_01" successfully completed at Thu Jul 21 14:34:03 2016 elapsed 0 00:00:06
[oracle@rhel6 ~]$ exit
exit

使e1和e2都应用flashback_scn

zx@ORCL>select count(*) from e1 where id in( select id from e2 as of scn 2179047 where birthday<sysdate);
  COUNT(*)
----------
31
zx@ORCL>host
[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\<sysdate\)\"  flashback_scn=2179047
Export: Release 11.2.0.4.0 - Production on Thu Jul 21 14:39:52 2016
Copyright (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 Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Starting "ZX"."SYS_EXPORT_TABLE_01":  zx/******** directory=dir dumpfile=e1_5.dmp tables=zx.e1 query=zx.e1:"where id in ( select id from e2 as of scn2179047 where birthday<sysdate)" flashback_scn=2179047 
Estimate in progress using BLOCKS method...
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 64 KB
Processing object type TABLE_EXPORT/TABLE/TABLE
. . exported "ZX"."E1"                                   6.757 KB      50 rows
Master table "ZX"."SYS_EXPORT_TABLE_01" successfully loaded/unloaded
******************************************************************************

多个表使用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 2016
Copyright (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 Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
FLASHBACK 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_DATA
Total estimation using BLOCKS method: 384 KB
Processing object type TABLE_EXPORT/TABLE/TABLE
. . exported "ZX"."ABC"                                  5.898 KB       2 rows
. . exported "ZX"."ABCE"                                 5.898 KB       2 rows
Master table "SYSTEM"."SYS_EXPORT_TABLE_01" successfully loaded/unloaded
******************************************************************************
Dump file set for SYSTEM.SYS_EXPORT_TABLE_01 is:
  /home/oracle/query.dmp
Job "SYSTEM"."SYS_EXPORT_TABLE_01" successfully completed at Fri Dec 9 16:14:04 2016 elapsed 0 00:00:19


您可能感兴趣的文档:

--结束END--

本文标题: Oracle 11g expdp中query参数的使用

本文链接: https://www.lsjlt.com/news/40144.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
  • expdp之query、flashback_scn参数的使用
    实验环境 操作系统:CentOS 7.1 数据库:Oracle 11.2.0.4   在使用10g后的Oracle Data Pump导出数据时, expdp中提供了...
    99+
    2024-04-02
  • oracle 11g常用隐含参数
    ORACLE 11GR2常用参数(含隐含参数)设置如下: alter system set "_PX_use_large_pool" = true scope=spfile; alter system se...
    99+
    2024-04-02
  • 【EXPDP】使用EXPDP备份数据时预估大小——ESTIMATE参数
    使用EXPDP在完成数据导出时,可以使用ESTIMATE参数评估待导出数据库对象的大小,简单演示一下,供参考。1.查看有关ESTIMATE参数的帮助信息1)查看命令行帮助信息ora10g@secDB /expdp$ expdp help=y...
    99+
    2023-06-06
  • oracle中Parallel参数的使用
    在Oracle数据库中,Parallel参数用于控制并行查询和并行DML操作的行为。以下是一些常见的Parallel参数及其使用方法...
    99+
    2023-08-08
    oracle
  • vue中如何使用params、query传参
    这篇文章主要介绍vue中如何使用params、query传参,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!声明式:<router-link :to="..."...
    99+
    2024-04-02
  • Oracle 11g 使用RMAN备份数据库
    使用Oracle自带的备份恢复工具RMAN(Recovery Manager)具有以下几种优势:支持增量备份能自动管理备份文件自动化备份与恢复备份的文件有效性检查配置快闪恢复区(flash recovery...
    99+
    2024-04-02
  • expdp/impdp如何使用version参数跨版本数据迁移
    小编给大家分享一下expdp/impdp如何使用version参数跨版本数据迁移,相信大部分人都还不怎么了解,因此分享这篇文章给大家参考一下,希望大家阅读完这篇文章后大有收获,下面让我们一起去了解一下吧! ...
    99+
    2024-04-02
  • oracle中的arallel参数怎么使用
    在Oracle中,Parallel参数用来控制并行查询的执行方式。以下是一些常见的使用方法:1. 对表或索引对象启用并行化:可以使用...
    99+
    2023-08-08
    oracle arallel
  • JS如何获取URL中的Query参数
    目录JS获取URL的Query参数需求描述实现一实现二JS获取URL上的指定参数总结JS获取URL的Query参数 需求描述 获取 URL 中的 Query 参数,例如: https...
    99+
    2023-01-17
    JS Query参数 JS获取URL的Query参数 JS获取Query参数
  • Oracle中使用optimizer_mode参数的意义
    本篇内容介绍了“Oracle中使用optimizer_mode参数的意义”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能...
    99+
    2024-04-02
  • oracle中如何使用exp/imp导入11g数据到9i
    这篇文章将为大家详细讲解有关oracle中如何使用exp/imp导入11g数据到9i,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。 方法1:导出导入都使用11g客户端 ...
    99+
    2024-04-02
  • oracle数据库的impdp,expdp有什么作用
    本篇内容介绍了“oracle数据库的impdp,expdp有什么作用”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学...
    99+
    2024-04-02
  • vue路由$router.push()使用query传参的实际开发使用
    目录前言一、vue-router是什么?二、router.push()方法三、vue-router传递的参数四.实际开发使用1.query传参使用案例(数据传递)2.读入数据补充:t...
    99+
    2022-11-16
    vue路由$router.push() vue 获取query传过来的参数 vue router query传参
  • 如何使用yum源安装oracle 11g数据库
    这篇文章主要介绍了如何使用yum源安装oracle 11g数据库,具有一定借鉴价值,感兴趣的朋友可以参考下,希望大家阅读完这篇文章之后大有收获,下面让小编带着大家一起了解一下。***************...
    99+
    2024-04-02
  • 如何在vue3+ts项目中使用query和params传参
    目录一 query 传参 (类似get请求)query 传参方式①query 传参方式② query 传参方式③二 params 传参 (类似post请求)params 传...
    99+
    2023-05-16
    vue query和params传参区别 vue的query传参 vue的params传参
  • CSS3中Media Query的使用方法
    这篇文章主要介绍“CSS3中Media Query的使用方法”,在日常操作中,相信很多人在CSS3中Media Query的使用方法问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解...
    99+
    2024-04-02
  • Oracle expdp导出多表或表中的部分数据
    环境:Oracle database 11gR2,  RHEL 5.4...
    99+
    2023-06-06
  • vue使用query传参页面刷新数据丢失怎么解决
    本篇内容介绍了“vue使用query传参页面刷新数据丢失怎么解决”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!vue路由传参(使用query...
    99+
    2023-07-06
  • PHP中的PDO::query()的使用方法
    这篇文章给大家分享的是有关PHP中的PDO::query()的使用方法的内容。小编觉得挺实用的,因此分享给大家做个参考,一起跟随小编过来看看吧。php是什么语言php,一个嵌套的缩写名称,是英文超级文本预处理语言(PHP:Hypertext...
    99+
    2023-06-14
  • Oracle 11g下编译使用BBED的方法教程
    BBED介绍: BBED(Oracle Block Browerand EDitor Tool),用来直接查看和修改数据文件数据的一个工具,是Oracle一款内部工具,可以直接修改Oracle数据文件块的内...
    99+
    2024-04-02
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作