一个项目中需要在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. 0004 工程配置settings.py

    两个目录的区别: 工程目录是指包含manage.py文件的目录 配置目录是批包含settings.py文件的目录 在配置目录中找到并打工settings.py文件,做以下配置: 01 DEBUG DE ...

  2. Selenium3+python自动化007-Selenium常用定位方法

    自动化测试只要掌握四步操作:获取元素,操作元素,获取返回结果,断言(返回结果与期望结果是否一致),最后自动出测试报告.元素定位在这四个环节中是至关重要的,如果说按学习精力分配的话,元素定位占70%:操 ...

  3. linux - 异常:安装包冲突 conflicts with

    问题描述 解决方案 删除冲突的包 命令格式:yum -y remove 包名 yum -y remove httpd24u yum -y remove httpd24u-tools

  4. 使用node搭建静态资源服务器

    安装 npm install yumu-static-server -g 使用 shift+鼠标右键  在此处打开Powershell 窗口 server # 会在当前目录下启动一个静态资源服务器,默 ...

  5. Windows ThinPC 7 部署后续设置与本地化

    还原注销背景 %system32%\oobe\info\backgrounds 删除该目录下所有文件后变为wes7背景 24时制与非UNICODE字符乱码解决 Control Panel \ Regi ...

  6. HTML link标签

    <link> 标签定义文档与外部资源的关系. 最常见的用途是链接 样式表.CSS

  7. R Tidyverse dplyr包学习笔记2

    Tidyverse 学习笔记 1.gapminder 我理解的gapminder应该是一个内置的数据集 加载之后使用 > # Load the gapminder package > li ...

  8. 洛谷P2158 [SDOI2008]仪仗队 欧拉函数的应用

    https://www.luogu.org/problem/P2158 #include<bits/stdc++.h> #define int long long using namesp ...

  9. oracle 锁表处理

    1.查询 select object_name,machine,s.sid,s.serial#from v$locked_object l,dba_objects o ,v$session swher ...

  10. manifold learning

    MDS, multidimensional scaling, 线性降维方法, 目的就是使得降维之后的点两两之间的距离尽量不变(也就是和在原是空间中对应的两个点之间的距离要差不多).只是 MDS 是针对 ...