Oracle expdp 多表导出处理
一个项目中需要在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 多表导出处理的更多相关文章
- oracle expdp impdp 导入导出备份
数据库导入导出: 使用EXPDP和IMPDP时应该注意的事项: EXP和IMP是客户端工具程序,它们既可以在客户端使用,也可以在服务端使用. EXPDP和IMPDP是服务端的工具程序,他们只能在ORA ...
- Oracle expdp数据泵导出,并在文件上附加上日期格式
一.导出操作的计算机要安装Oracle Client(建议管理员版本) 二.在服务端创建目录 create directory dpdir as '目录'; 三.给目录赋权限 grant read,w ...
- Oracle odi 数据表导出到文件
最近新客户要求,以EXCEL数据方式,将数据表的内容,通过AS2协议传输到客户那边,本来打算使用存储过程直接输出EXCEL,但一想,ODI这么强大的工具应该可以直接进行转换,所以参考了一下官方标准文档 ...
- oracle 11g 空表导出
背景 oracle9用了一段时间,10用了一段时间,11现在算是主流了.11g也是坑人,空表竟然不导出,解决方法到时很多.这里只是记录下,知道有这个事情. 9的特点是还要用客户端管理工具链接服务器 1 ...
- Oracle expdp按分区导出生成参数文件
使用dba_tab_partitions视图获得每个分区的参数文件内容,使用chr(10)分行 select 'content=data_only'||chr(10)|| 'directory=dat ...
- Oracle EXPDP导出数据
Oracle expdp导出表数据(带条件): expdp student/123456@orcl dumpfile=student_1.dmp logfile=student_1.log table ...
- oracle expdp/impdp/可传输表空间
oracle expdp/impdp/可传输表空间/及一些参数 Oracle data pump 导出操作能够将表.索引.约束.权限.PLSQL包.同义词等对象从数据库导出,并将它们保存在一种非文本格 ...
- Oracle 数据泵(IMPDP/EXPDP)导入导出总结
Oracle数据泵导入导出是日常工作中常用的基本技术之一,它相对传统的逻辑导入导出要高效,这种特性更适合数据库对象数量巨大的情形,因为我日常运维的数据库对象少则几千,多则几万甚至几十万,所以传统exp ...
- Oracle expdp导出分区表,query条件带有rownum
Oracle expdp导出分区表,query条件带有rownum 前言 在做数据脱敏的时候,对一张刚好是分区表的表做导出,为了只取出部分数据看是否数据可以正常脱敏,在query中带上rownum. ...
随机推荐
- 51 nod 1212 无向图最小生成树
http://www.51nod.com/Challenge/Problem.html#problemId=1212 代码 #include<bits/stdc++.h> using na ...
- CSS的文本样式
CSS的文本样式 1.颜色 2.文本对齐方式 3.首行缩进 4.行高 5.装饰 1. 文本位置 居中: text-align: center; 靠左: text-align: left; 靠右: te ...
- LaTeX绘图
http://math.uchicago.edu/~weinan/programs/tex_diagrams/diagrams.html 给大家分享下这个,用鼠标画diagrams,然后可以一键复制l ...
- Wannafly Camp 2020 Day 2J 邦邦的2-SAT模板
#include <bits/stdc++.h> using namespace std; int main() { int n; cin>>n; cout<<n& ...
- IDEA更换背景颜色与字体
打开IDEA 选择左上角的File -> Setting -> Editor -> Color Scheme 就可以设置 黑白背景 默认为白色 可以选择 Darcul ...
- C++-POJ2975-Nim
题目把Nim游戏为什么可以取异或和讲解得十分清楚,建议多读几次,理解一下 再一个,可以把每次异或视为一次取数,因此(k[i]^sg)<k[i]即为一种可行操作 /* Nim is a 2-pla ...
- 洛谷P1223 排队接水
https://www.luogu.org/problem/P1223 #include<bits/stdc++.h> using namespace std; struct st { i ...
- SpringBoot集成flowable碰见DMN不能初始化
在idea创建了SpringBoot项目,集成flowable,运行的时候DMN引擎初始化失败,花了一天时间也没解决. 抱着试试的态度重新建立一个项目,加入同样的依赖,成功运行. 但把成功运行的项目配 ...
- [C语言学习笔记四]变量与系统的交互
使用 const 创建常量和使用 volatie 优化变量 C语言中使用 const 定义常量. 例如: const INT a = 10; 此处如果添加a = 20;,编辑器则会报错,因为此处 a ...
- 【蓝桥杯/算法训练】Sticks 剪枝算法
剪枝算法 大概理解是通过分析问题,发现一些判断条件,避免不必要的搜索.通常应用在DFS 和 BFS 搜索算法中:剪枝策略就是寻找过滤条件,提前减少不必要的搜索路径. 问题描述 George took ...