一个项目中需要在oracle数据库某个用户下导出1000多个表,导入到测试库做数据分析测试。很少遇到需要导出这么多表的情况,通常都是按schema导出,或者整库导出。考虑到expdp中include参数可以附带查询语句,本次遇到的需要导出大量具体表的建议思路:

  1) 在数据库中建一个表exptable,把需要导出表的表明插入到该表中;

  2)利用expdp导出命令的include参数附带select语句查询exptable表,获得需要导出的表名;

  3)开始导出。

过程记录如下:

1 在数据库中建立一个导出列表exptable

create table exptable (id number(10),tablename varchar2(20));

2 使用sql*load工具把需要导出的表的名称输入到exptable中:

2.1 把需要导出的表名另存为txt文本,id和表名之间用空格隔开,每行以逗号结尾;

2.2 创建ctl文件:

[oracle@jxsbwxdb1 ~]$ cat a.ctl

  load data
  infile '/home/oracle/exptable.txt'
  append into table jxsi.exptable
  fields terminated by ',' trailing nullcols
  (id,tablename)

2.3 使用命令sqlldr输入数据

sqlldr jxsi/****** control=a.ctl

SQL*Loader: Release 11.2.0.4.0 - Production on Wed Feb 26 22:39:04 2020

Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.

Control File: a.ctl
Data File: /home/oracle/exptable.txt
Bad File: exptable.bad
Discard File: none specified

(Allow all discards)

Number to load: ALL
Number to skip: 0
Errors allowed: 50
Bind array: 64 rows, maximum of 256000 bytes
Continuation: none specified
Path used: Conventional

Table JXSI.EXPTABLE, loaded from every logical record.
Insert option in effect for this table: APPEND
TRAILING NULLCOLS option in effect

Column Name Position Len Term Encl Datatype
------------------------------ ---------- ----- ---- ---- ---------------------
ID FIRST * , CHARACTER
TABLENAME NEXT * , CHARACTER

Table JXSI.EXPTABLE:
1056 Rows successfully loaded.
0 Rows not loaded due to data errors.
0 Rows not loaded because all WHEN clauses were failed.
0 Rows not loaded because all fields were null.

Space allocated for bind array: 33024 bytes(64 rows)
Read buffer bytes: 1048576

Total logical records skipped: 0
Total logical records read: 1056
Total logical records rejected: 0
Total logical records discarded: 0

Run began on Wed Feb 26 22:39:04 2020
Run ended on Wed Feb 26 22:39:04 2020

Elapsed time was: 00:00:00.13
CPU time was: 00:00:00.01

查询数据确认是否正确导入:

SQL> select count(*) from exptable;

COUNT(*)
----------
1056

  

3.expdp导出语句

expdp system/****** parfile=exptable.par

cat exptable.par

dumpfile=20200226_exptable_%U.dmp
logfile=20200226_exptable.log
schemas=jxsi
directory=DPDATA
PARALLEL=4
COMPRESSION=all
cluster=N
include=TABLE:"IN (select tablename from exptable where tablename is not null)"

或者:

expdp jxsi/****** directory=DPDATA dumpfile=20200226_exptable_%U.dmp schemas=jxsi include=table:\"in \(select tablename from exptable \)\" logfile=20200226_exptable.log cluster=N compression=all PARALLEL=4

  

Export: Release 11.2.0.4.0 - Production on Wed Feb 26 22:40:52 2020

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, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options
FLASHBACK automatically enabled to preserve database integrity.
Starting "JXSI"."SYS_EXPORT_SCHEMA_02": jxsi/******** directory=DPDATA dumpfile=20200226_exptable_%U.dmp schemas=jxsi include=table:"in (select tablename from exptable )" logfile=20200226_exptable.log cluster=N compression=all PARALLEL=4
Estimate in progress using BLOCKS method...
Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 220.7 GB
Processing object type SCHEMA_EXPORT/TABLE/PROCACT_INSTANCE
Processing object type SCHEMA_EXPORT/TABLE/TABLE
Processing object type SCHEMA_EXPORT/TABLE/GRANT/OWNER_GRANT/OBJECT_GRANT
Processing object type SCHEMA_EXPORT/TABLE/COMMENT
Processing object type SCHEMA_EXPORT/TABLE/INDEX/INDEX
Processing object type SCHEMA_EXPORT/TABLE/INDEX/FUNCTIONAL_INDEX/INDEX
Processing object type SCHEMA_EXPORT/TABLE/CONSTRAINT/CONSTRAINT
Processing object type SCHEMA_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
Processing object type SCHEMA_EXPORT/TABLE/INDEX/STATISTICS/FUNCTIONAL_INDEX/INDEX_STATISTICS
Processing object type SCHEMA_EXPORT/TABLE/INDEX/BITMAP_INDEX/INDEX
Processing object type SCHEMA_EXPORT/TABLE/INDEX/STATISTICS/BITMAP_INDEX/INDEX_STATISTICS
Processing object type SCHEMA_EXPORT/TABLE/TRIGGER
Processing object type SCHEMA_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
Processing object type SCHEMA_EXPORT/TABLE/POST_TABLE_ACTION
. . exported "JXSI"."AC43":"AC43_20" 1.890 GB 81857509 rows
. . exported "JXSI"."AC43":"AC43_10" 2.110 GB 94683422 rows

......

. . exported "JXSI"."P_RYQY" 4.921 KB 21 rows
. . exported "JXSI"."QTMXB" 10.15 KB 234 rows
Master table "JXSI"."SYS_EXPORT_SCHEMA_02" successfully loaded/unloaded
******************************************************************************
Dump file set for JXSI.SYS_EXPORT_SCHEMA_02 is:
/tmpbak/DPDATA/20200226_exptable_01.dmp
/tmpbak/DPDATA/20200226_exptable_02.dmp
/tmpbak/DPDATA/20200226_exptable_03.dmp
/tmpbak/DPDATA/20200226_exptable_04.dmp
Job "JXSI"."SYS_EXPORT_SCHEMA_02" successfully completed at Wed Feb 26 23:22:23 2020 elapsed 0 00:41:30

正常导出。

Oracle expdp 多表导出处理的更多相关文章

  1. oracle expdp impdp 导入导出备份

    数据库导入导出: 使用EXPDP和IMPDP时应该注意的事项: EXP和IMP是客户端工具程序,它们既可以在客户端使用,也可以在服务端使用. EXPDP和IMPDP是服务端的工具程序,他们只能在ORA ...

  2. Oracle expdp数据泵导出,并在文件上附加上日期格式

    一.导出操作的计算机要安装Oracle Client(建议管理员版本) 二.在服务端创建目录 create directory dpdir as '目录'; 三.给目录赋权限 grant read,w ...

  3. Oracle odi 数据表导出到文件

    最近新客户要求,以EXCEL数据方式,将数据表的内容,通过AS2协议传输到客户那边,本来打算使用存储过程直接输出EXCEL,但一想,ODI这么强大的工具应该可以直接进行转换,所以参考了一下官方标准文档 ...

  4. oracle 11g 空表导出

    背景 oracle9用了一段时间,10用了一段时间,11现在算是主流了.11g也是坑人,空表竟然不导出,解决方法到时很多.这里只是记录下,知道有这个事情. 9的特点是还要用客户端管理工具链接服务器 1 ...

  5. Oracle expdp按分区导出生成参数文件

    使用dba_tab_partitions视图获得每个分区的参数文件内容,使用chr(10)分行 select 'content=data_only'||chr(10)|| 'directory=dat ...

  6. Oracle EXPDP导出数据

    Oracle expdp导出表数据(带条件): expdp student/123456@orcl dumpfile=student_1.dmp logfile=student_1.log table ...

  7. oracle expdp/impdp/可传输表空间

    oracle expdp/impdp/可传输表空间/及一些参数 Oracle data pump 导出操作能够将表.索引.约束.权限.PLSQL包.同义词等对象从数据库导出,并将它们保存在一种非文本格 ...

  8. Oracle 数据泵(IMPDP/EXPDP)导入导出总结

    Oracle数据泵导入导出是日常工作中常用的基本技术之一,它相对传统的逻辑导入导出要高效,这种特性更适合数据库对象数量巨大的情形,因为我日常运维的数据库对象少则几千,多则几万甚至几十万,所以传统exp ...

  9. Oracle expdp导出分区表,query条件带有rownum

    Oracle expdp导出分区表,query条件带有rownum 前言 在做数据脱敏的时候,对一张刚好是分区表的表做导出,为了只取出部分数据看是否数据可以正常脱敏,在query中带上rownum. ...

随机推荐

  1. laravel框架使用阿里短信接入

    EG: accessKeyid和accessKeySecret还有模板ID.签名名称这几项必要参数自己去阿里云获取一.下载SDK和demo 下载并解压后 在laravel框架的app目录下创建libs ...

  2. java面试记录二:spring加载流程、springmvc请求流程、spring事务失效、synchronized和volatile、JMM和JVM模型、二分查找的实现、垃圾收集器、控制台顺序打印ABC的三种线程实现

    注:部分答案引用网络文章 简答题 1.Spring项目启动后的加载流程 (1)使用spring框架的web项目,在tomcat下,是根据web.xml来启动的.web.xml中负责配置启动spring ...

  3. PHP实现微信公众号授权获取用户信息

    class WxAuthModel extends BaseModel { var $appId = APPID; var $appSecret = APPSECRET; /*微信x小程序,获取微信o ...

  4. Selenium3+python自动化009- 截图

    一.断言 assert cur_title=='百度一下,你就知道1','title断言失败' 'title断言失败':自定义报错 二.截图 # 调用截屏方法(路径+截图名称)driver.get_s ...

  5. ubuntu19.04 redis启动和停止及连接

    1.启动停止 如果以(sudo apt install redis-server)方式安装 启动: sudo srevice redis start 停止:     sudo srevice redi ...

  6. ETag使用

    关于ETag相关知识: https://blog.csdn.net/kikikind/article/details/6266101  https://blog.csdn.net/jkxiaoxing ...

  7. JS高级---沙箱小案例

    沙箱小案例 substr截取, 从指定的字段开始截取 (function () { var str="小白喜欢小黑"; str=str.substr(2); console.log ...

  8. 给阿里云主机添加swap分区,解决问题:c++: internal compiler error: Killed (program cc1plus)

    前言 今天安装spdlog,一个快速得C++日志库,按照文档步骤,不料出现了一堆错误,像c++: internal compiler error: Killed (program cc1plus)等一 ...

  9. 如何把U盘的两个盘或者多个盘合成一个

    1.插入U盘,导出所有重要数据. 2.右击我的电脑,点管理打开设备管理器. 3.在设备管理器里找到磁盘管理. 4.在磁盘管理右侧出现下图: 5.如图是windows 7的界面. 6.找到U盘,图上是磁 ...

  10. MyBatis-单表的增删改查(CRUD)操作

          在学习MyBatis的单表的增删改查操作之前,还是再次熟悉下MyBatis这个框架,只有对其熟悉的情况下,才能很好的使用,灵活的开发.         MyBatis优点:         ...