oracle中include,impdpexpdp的content和include选项
由于导出和导入时需要关注索引是否被导入,进行实验。
本实验主要目的是理解content的两个参数项:date_only和metadata_only,其中涉及include。
1.分别使用以下三种方式导出分区表ACTIVE_PARTITION的数据、元数据
expdp scott/scott
directory=HOME_O
dumpfile=scott_expdp1.dmp
logfile=scott_expdp1.log tables=ACTIVE_PARTITION
expdp scott/scott
directory=HOME_O
dumpfile=scott_expdp2.dmp
logfile=scott_expdp2.log tables=ACTIVE_PARTITION content=data_only
expdp scott/scott
directory=HOME_O
dumpfile=scott_expdp3.dmp
logfile=scott_expdp3.log tables=ACTIVE_PARTITION content=metadata_only
[oracle@ogg2 ~]$
expdp scott/scott directory=HOME_O dumpfile=scott_expdp1.dmp logfile=scott_expdp1.log
tables=ACTIVE_PARTITION
Export: Release
11.2.0.1.0 - Production on Mon Mar 9 14:45:17 2015
Copyright (c) 1982,
2009, Oracle and/or its affiliates. All
rights reserved.
Connected to: Oracle
Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the
Partitioning, OLAP, Data Mining and Real Application Testing options
Starting
"SCOTT"."SYS_EXPORT_TABLE_02": scott/******** directory=HOME_O
dumpfile=scott_expdp1.dmp logfile=scott_expdp1.log tables=ACTIVE_PARTITION
Estimate in progress
using BLOCKS method...
Processing object
type TABLE_EXPORT/TABLE/TABLE_DATA
Total estimation
using BLOCKS method: 8.5 MB
Processing object
type TABLE_EXPORT/TABLE/TABLE
Processing object
type TABLE_EXPORT/TABLE/CONSTRAINT/CONSTRAINT
Processing object
type TABLE_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
Processing object
type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
. . exported
"SCOTT"."ACTIVE_PARTITION":"P5" 5.896 MB 60275 rows
. . exported
"SCOTT"."ACTIVE_PARTITION":"P4" 459.5 KB 5033 rows
. . exported
"SCOTT"."ACTIVE_PARTITION":"P3" 385.1 KB 3834 rows
. . exported
"SCOTT"."ACTIVE_PARTITION":"P1" 280.8 KB 2847 rows
. . exported
"SCOTT"."ACTIVE_PARTITION":"P2" 31.52 KB 226 rows
Master table
"SCOTT"."SYS_EXPORT_TABLE_02" successfully loaded/unloaded
******************************************************************************
Dump file set for
SCOTT.SYS_EXPORT_TABLE_02 is:
/home/oracle/scott_expdp1.dmp
Job
"SCOTT"."SYS_EXPORT_TABLE_02" successfully completed at
14:45:28
[oracle@ogg2 ~]$
expdp scott/scott directory=HOME_O dumpfile=scott_expdp2.dmp logfile=scott_expdp2.log
tables=ACTIVE_PARTITION content=data_only
Export: Release
11.2.0.1.0 - Production on Mon Mar 9 14:45:41 2015
Copyright (c) 1982,
2009, Oracle and/or its affiliates. All
rights reserved.
Connected to: Oracle
Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the
Partitioning, OLAP, Data Mining and Real Application Testing options
Starting
"SCOTT"."SYS_EXPORT_TABLE_02": scott/******** directory=HOME_O
dumpfile=scott_expdp2.dmp logfile=scott_expdp2.log tables=ACTIVE_PARTITION
content=data_only
Estimate in progress
using BLOCKS method...
Processing object
type TABLE_EXPORT/TABLE/TABLE_DATA
Total estimation
using BLOCKS method: 8.5 MB
. . exported
"SCOTT"."ACTIVE_PARTITION":"P5" 5.896 MB 60275 rows
. . exported
"SCOTT"."ACTIVE_PARTITION":"P4" 459.5 KB 5033 rows
. . exported
"SCOTT"."ACTIVE_PARTITION":"P3" 385.1 KB 3834 rows
. . exported
"SCOTT"."ACTIVE_PARTITION":"P1" 280.8 KB 2847 rows
. . exported
"SCOTT"."ACTIVE_PARTITION":"P2" 31.52 KB 226 rows
Master table
"SCOTT"."SYS_EXPORT_TABLE_02" successfully loaded/unloaded
******************************************************************************
Dump file set for
SCOTT.SYS_EXPORT_TABLE_02 is:
/home/oracle/scott_expdp2.dmp
Job
"SCOTT"."SYS_EXPORT_TABLE_02" successfully completed at
14:45:47
[oracle@ogg2 ~]$
expdp scott/scott directory=HOME_O dumpfile=scott_expdp3.dmp logfile=scott_expdp3.log
tables=ACTIVE_PARTITION content=metadata_only
Export: Release
11.2.0.1.0 - Production on Mon Mar 9 14:45:56 2015
Copyright (c) 1982,
2009, Oracle and/or its affiliates. All
rights reserved.
Connected to: Oracle
Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the
Partitioning, OLAP, Data Mining and Real Application Testing options
Starting
"SCOTT"."SYS_EXPORT_TABLE_02": scott/******** directory=HOME_O
dumpfile=scott_expdp3.dmp logfile=scott_expdp3.log tables=ACTIVE_PARTITION
content=metadata_only
Processing object
type TABLE_EXPORT/TABLE/TABLE
Processing object
type TABLE_EXPORT/TABLE/CONSTRAINT/CONSTRAINT
Processing object
type TABLE_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
Processing object
type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
Master table
"SCOTT"."SYS_EXPORT_TABLE_02" successfully loaded/unloaded
******************************************************************************
Dump file set for
SCOTT.SYS_EXPORT_TABLE_02 is:
/home/oracle/scott_expdp3.dmp
Job
"SCOTT"."SYS_EXPORT_TABLE_02" successfully completed at
14:46:06
2.新建用户scott2,授予权限(实验中粗糙授权)
SQL> create user
scott2 identified by scott2;
User created.
SQL> grant dba to
scott2;
Grant succeeded.
SQL> grant
connect ,resource to scott2;
Grant succeeded.
3.使用第一种方式导出的数据,导入时索引和数据都会被导入
[oracle@ogg2 ~]$
impdp scott2/scott2 directory=HOME_O dumpfile=scott_expdp1.dmp logfile=scott_impdp1.log
remap_schema=scott:scott2
Import: Release
11.2.0.1.0 - Production on Mon Mar 9 14:49:55 2015
Copyright (c) 1982,
2009, Oracle and/or its affiliates. All
rights reserved.
Connected to: Oracle
Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the
Partitioning, OLAP, Data Mining and Real Application Testing options
Master table
"SCOTT2"."SYS_IMPORT_FULL_01" successfully loaded/unloaded
Starting
"SCOTT2"."SYS_IMPORT_FULL_01": scott2/******** directory=HOME_O
dumpfile=scott_expdp1.dmp logfile=scott_impdp1.log remap_schema=scott:scott2
Processing object
type TABLE_EXPORT/TABLE/TABLE
Processing object
type TABLE_EXPORT/TABLE/TABLE_DATA
. . imported
"SCOTT2"."ACTIVE_PARTITION":"P5" 5.896 MB 60275 rows
. . imported
"SCOTT2"."ACTIVE_PARTITION":"P4" 459.5 KB 5033 rows
. . imported
"SCOTT2"."ACTIVE_PARTITION":"P3" 385.1 KB 3834 rows
. . imported
"SCOTT2"."ACTIVE_PARTITION":"P1" 280.8 KB 2847 rows
. . imported
"SCOTT2"."ACTIVE_PARTITION":"P2" 31.52 KB 226 rows
Processing object
type TABLE_EXPORT/TABLE/CONSTRAINT/CONSTRAINT
Processing object
type TABLE_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
Processing object
type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
Job
"SCOTT2"."SYS_IMPORT_FULL_01" successfully completed at
14:53:28
SQL> set lines
200
SQL> select
index_name,owner,index_type from dba_indexes where
table_name='ACTIVE_PARTITION';
INDEX_NAME OWNER INDEX_TYPE
------------------------------
------------------------------ ---------------------------
SYS_C0011466 SCOTT2 NORMAL
SYS_C0011431 SCOTT NORMAL
SQL> select
TABLE_OWNER,TABLE_NAME,partition_name from dba_tab_partitions where
table_name='ACTIVE_PARTITION' and table_owner='SCOTT2';
TABLE_OWNER TABLE_NAME PARTITION_NAME
------------------------------
------------------------------ ------------------------------
SCOTT2 ACTIVE_PARTITION P1
SCOTT2 ACTIVE_PARTITION P2
SCOTT2 ACTIVE_PARTITION P3
SCOTT2 ACTIVE_PARTITION P4
SCOTT2 ACTIVE_PARTITION P5
SQL> drop table
scott2.active_partition;
Table dropped.
SQL> exit
Disconnected from
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the
Partitioning, OLAP, Data Mining and Real Application Testing options
4.使用第二种方式导入,由于没有表结构,会报错
[oracle@ogg2 ~]$
impdp scott2/scott2 directory=HOME_O dumpfile=scott_expdp2.dmp logfile=scott_impdp2.log
remap_schema=scott:scott2
Import: Release
11.2.0.1.0 - Production on Mon Mar 9 15:00:30 2015
Copyright (c) 1982,
2009, Oracle and/or its affiliates. All
rights reserved.
Connected to: Oracle
Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the
Partitioning, OLAP, Data Mining and Real Application Testing options
Master table
"SCOTT2"."SYS_IMPORT_FULL_01" successfully loaded/unloaded
Starting
"SCOTT2"."SYS_IMPORT_FULL_01": scott2/******** directory=HOME_O
dumpfile=scott_expdp2.dmp logfile=scott_impdp2.log remap_schema=scott:scott2
Processing object
type TABLE_EXPORT/TABLE/TABLE_DATA
ORA-39126: Worker
unexpected fatal error in KUPW$WORKER.UPATE_TD_ROW_IMP [15]
TABLE_DATA:"SCOTT2"."ACTIVE_PARTITION":"P1"
ORA-31603: object
"ACTIVE_PARTITION" of type TABLE not found in schema
"SCOTT2"
ORA-06512: at
"SYS.DBMS_SYS_ERROR", line 105
ORA-06512: at
"SYS.KUPW$WORKER", line 8170
----- PL/SQL Call
Stack -----
object
line object
handle
number name
0x43301f90 19028
package body SYS.KUPW$WORKER
0x43301f90 8191
package body SYS.KUPW$WORKER
0x43301f90 18608
package body SYS.KUPW$WORKER
0x43301f90 4104
package body SYS.KUPW$WORKER
0x43301f90 8874
package body SYS.KUPW$WORKER
0x43301f90 1651
package body SYS.KUPW$WORKER
0x455bc588 2
anonymous block
ORA-39126: Worker
unexpected fatal error in KUPW$WORKER.UPATE_TD_ROW_IMP [15]
TABLE_DATA:"SCOTT2"."ACTIVE_PARTITION":"P1"
ORA-31603: object
"ACTIVE_PARTITION" of type TABLE not found in schema
"SCOTT2"
ORA-06512: at
"SYS.DBMS_SYS_ERROR", line 105
ORA-06512: at
"SYS.KUPW$WORKER", line 8170
----- PL/SQL Call
Stack -----
object
line object
handle
number name
0x43301f90 19028
package body SYS.KUPW$WORKER
0x43301f90 8191
package body SYS.KUPW$WORKER
0x43301f90 18608
package body SYS.KUPW$WORKER
0x43301f90 4104
package body SYS.KUPW$WORKER
0x43301f90 8874
package body SYS.KUPW$WORKER
0x43301f90 1651
package body SYS.KUPW$WORKER
0x455bc588 2
anonymous block
Job
"SCOTT2"."SYS_IMPORT_FULL_01" stopped due to fatal error at
15:00:36
5.content=metadata_only表示只导入结构,不导入数据;而content=data_only是只导入数据。两者依次导入则等同于不加该参数。
如果需要在导入时排除索引,可以添加其他参数。
下面使用exclude=index是无效的,从导入日志可以看到导入了CONSTRAINT,因此主键索引、唯一键索引都被导入了
[oracle@ogg2 ~]$
impdp scott2/scott2 directory=HOME_O dumpfile=scott_expdp3.dmp logfile=scott_impdp3.log
remap_schema=scott:scott2 exclude=index
Import: Release
11.2.0.1.0 - Production on Mon Mar 9 15:14:16 2015
Copyright (c) 1982,
2009, Oracle and/or its affiliates. All
rights reserved.
Connected to: Oracle
Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the
Partitioning, OLAP, Data Mining and Real Application Testing options
Master table
"SCOTT2"."SYS_IMPORT_FULL_02" successfully loaded/unloaded
Starting
"SCOTT2"."SYS_IMPORT_FULL_02": scott2/******** directory=HOME_O
dumpfile=scott_expdp3.dmp logfile=scott_impdp3.log remap_schema=scott:scott2
exclude=index
Processing object
type TABLE_EXPORT/TABLE/TABLE
Processing object
type TABLE_EXPORT/TABLE/CONSTRAINT/CONSTRAINT
Processing object
type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
Job
"SCOTT2"."SYS_IMPORT_FULL_02" successfully completed at
15:14:24
[oracle@ogg2 ~]$
sqlplus / as sysdba
SQL*Plus: Release
11.2.0.1.0 Production on Mon Mar 9 15:14:36 2015
Copyright (c) 1982,
2009, Oracle. All rights reserved.
Connected to:
Oracle Database 11g
Enterprise Edition Release 11.2.0.1.0 - Production
With the
Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> select
index_name,owner,index_type from dba_indexes where
table_name='ACTIVE_PARTITION';
INDEX_NAME OWNER
------------------------------
------------------------------
INDEX_TYPE
---------------------------
SYS_C0011477 SCOTT2
NORMAL
SYS_C0011431 SCOTT
NORMAL
SQL> drop table
scott2.ACTIVE_PARTITION;
Table dropped.
正确的方法是导入时指定include=table/table,然后导入数据
[oracle@ogg2 ~]$
impdp scott2/scott2 directory=HOME_O dumpfile=scott_expdp3.dmp logfile=scott_impdp3.log
remap_schema=scott:scott2 include=table/table
Import: Release
11.2.0.1.0 - Production on Mon Mar 9 15:20:12 2015
Copyright (c) 1982,
2009, Oracle and/or its affiliates. All
rights reserved.
Connected to: Oracle
Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the
Partitioning, OLAP, Data Mining and Real Application Testing options
Master table
"SCOTT2"."SYS_IMPORT_FULL_02" successfully loaded/unloaded
Starting
"SCOTT2"."SYS_IMPORT_FULL_02": scott2/******** directory=HOME_O
dumpfile=scott_expdp3.dmp logfile=scott_impdp3.log remap_schema=scott:scott2
include=table/table
Processing object
type TABLE_EXPORT/TABLE/TABLE
Job
"SCOTT2"."SYS_IMPORT_FULL_02" successfully completed at
15:20:18
[oracle@ogg2 ~]$
impdp scott2/scott2 directory=HOME_O dumpfile=scott_expdp2.dmp logfile=scott_impdp2.log
remap_schema=scott:scott2
Import: Release
11.2.0.1.0 - Production on Mon Mar 9 15:20:53 2015
Copyright (c) 1982,
2009, Oracle and/or its affiliates. All
rights reserved.
Connected to: Oracle
Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the
Partitioning, OLAP, Data Mining and Real Application Testing options
Master table
"SCOTT2"."SYS_IMPORT_FULL_02" successfully loaded/unloaded
Starting
"SCOTT2"."SYS_IMPORT_FULL_02": scott2/******** directory=HOME_O
dumpfile=scott_expdp2.dmp logfile=scott_impdp2.log remap_schema=scott:scott2
Processing object
type TABLE_EXPORT/TABLE/TABLE_DATA
. . imported
"SCOTT2"."ACTIVE_PARTITION":"P5" 5.896 MB 60275 rows
. . imported
"SCOTT2"."ACTIVE_PARTITION":"P4" 459.5 KB 5033 rows
. . imported
"SCOTT2"."ACTIVE_PARTITION":"P3" 385.1 KB 3834 rows
. . imported
"SCOTT2"."ACTIVE_PARTITION":"P1" 280.8 KB 2847 rows
. . imported
"SCOTT2"."ACTIVE_PARTITION":"P2" 31.52 KB 226 rows
Job
"SCOTT2"."SYS_IMPORT_FULL_02" successfully completed at
15:21:04
[oracle@ogg2 ~]$
sqlplus / as sysdba
SQL*Plus: Release
11.2.0.1.0 Production on Mon Mar 9 15:21:10 2015
Copyright (c) 1982,
2009, Oracle. All rights reserved.
Connected to:
Oracle Database 11g
Enterprise Edition Release 11.2.0.1.0 - Production
With the
Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> set lines
200
SQL> select
index_name,owner,index_type from dba_indexes where
table_name='ACTIVE_PARTITION';
INDEX_NAME OWNER INDEX_TYPE
------------------------------
------------------------------ ---------------------------
SYS_C0011431 SCOTT NORMAL
注意,这时只看到了scott下的索引,scott2下是没导入的。
include参数的格式为:
INCLUDE =
object_type[:name_clause] [, ...]
其中object_type指定了可以包含的对象类型,可以通过以下视图查看:
全局 select OBJECT_PATH?from
DATABASE_EXPORT_OBJECTS;
用户级 select
OBJECT_PATH?from SCHEMA_EXPORT_OBJECTS ;
表级 select OBJECT_PATH?from
TABLE_EXPORT_OBJECTS ;
name_clause是可选的,可以用双引号包含具体的对象名称。
根据官方文档建议(utility
87页):最好使用参数文件来包含此类需要添加较多双引号的参数。
如:
hr.par文件内容为:
SCHEMAS=HR
DUMPFILE=expinclude.dmp
DIRECTORY=dpump_dir1
LOGFILE=expinclude.log
INCLUDE=TABLE:"IN
('EMPLOYEES', 'DEPARTMENTS')"
INCLUDE=PROCEDURE
INCLUDE=INDEX:"LIKE
'EMP%'"
指定的导出(导入)语句为:
expdp hr
PARFILE=hr.par
oracle中include,impdpexpdp的content和include选项相关推荐
- python中双向索引_对索引Include子句的深入分析
翻译:陈雁飞 校对:李冉 作者简介 Markus Winand专注于传授高效的SQL技巧,有面授和网络课程两种.他使用现代SQL方法大大减少了开发时间,并且通过智能索引优化SQL运行时间.编写的&l ...
- python如何复制oracle数据_Python使用cx_Oracle模块将oracle中数据导出到csv文件的方法...
本文实例讲述了Python使用cx_Oracle模块将oracle中数据导出到csv文件的方法.分享给大家供大家参考.具体实现方法如下: # Export Oracle database tables ...
- ORACLE中的两个概念:user和schema的区别和联系
http://oracle.chinaitlab.com/induction/835839.html 今天重读ORACLE官方文档<concepts>,读到schema的基本概念,对它的理 ...
- oracle拼接字符串报错,Oracle 中wmsys.wm_concat拼接字符串,结果过长报错解决
备忘:这个函数最大是4000,根据拼接列的长度,通过限制拼接条数来防止拼接字符串过长错误 --这个情况是从子表中读取出具,这里直接把它当做查询字段处理,在子表中有所有数据 select info.id ...
- oracle substr(table),oracle中的substr()函数
SUBSTR(cExpression,nStartPosition [,nCharactersReturned]) 其中,cExpression指定要从其中返回字符串的字符表达式或备注字段: nSta ...
- oracle中schema是什么,ORACLE中的两个概念:user和schema的区别和联系
今天重读ORACLE官方文档<concepts>,读到schema的基本概念,对它的理解更进一层, 官方文档中关于schema是这样解释的: "A schema is a col ...
- oracle中private同义词和public同义词
项目中遇到,遂从网上搜索了下,觉得如下解释较为通俗易懂: 假设oracle有以下两个用户: admin , visitor 我们在admin下建立了 testtable 这个表,并且对visitor用 ...
- Oracle中V$SESSION等各表的字段解释,Oracle官方解释
https://www.cnblogs.com/grey-wolf/p/10119219.html Oracle中V$SESSION等各表的字段解释,Oracle官方解释 阅读目录 一.常用的视图 1 ...
- oracle中totimestamp,oracle中to_timestamp和to_date什么区别
date类型是Oracle常用的日期型变量,时间间隔是秒.两个日期型相减得到是两个时间的间隔,注意单位是"天". timestamp是DATE类型的扩展,可以精确到小数秒(frac ...
最新文章
- decode bytes in position 2-3: truncated \UXXXXXXXX escape
- Java虚拟机学习(2):垃圾收集算法
- 最简化Selenium环境安装
- 陕西科技大学18计算机调剂,2018年陕西科技大学考研调剂信息公布
- 2月份Web服务器份额:排名不变 仅Microsoft份额上扬
- U-Net++粗略解释
- 屏幕录像软件Bandicam和oCam
- Flink on Hive构建流批一体数仓
- 物联网中C语言与汇编语言,ARM Cortex-M架构CPU中C语言和汇编语言的混合编程
- 数据增强 | 现实应用思考
- RK3288_Android7.1调试RTC总结(二)
- 【渝粤教育】国家开放大学2018年春季 0688-22T老年精神障碍护理 参考试题
- [转] Ubuntu 16.04 RTL8111/8168/8411 不能上网 经常断网解决办法
- 【Android】Xposed 框架解析
- 坚果云企业版服务器端,坚果云企业版
- 网友上海求职指南2007
- 删除WIN10桌面右键菜单多余项的方法
- 自动化建模 | H2O开源工具介绍
- 非常强大的shell写的俄罗斯方块
- 谷歌地图-Google Map
热门文章
- jpg图片怎么转换为CAD图纸?简单几步教你操作
- msbuild 语法_如何通过命令行 msbuild 编译项目
- 24位AD和16位DA超高精度PID串级控制器在张力控制中的应用
- 每天睁开眼,开源众包就欠你60万!
- Hotel California 加州旅馆
- ArcGIS中克里金插值操作
- sim7600ce 拨号上网测试_Linux下sim7600ce调试笔记
- 干票大的,230万篇文章随你下载!
- 【CET4四级英语】【单词】英语四级高频词汇(3)
- 跨境网络赌博“易倍”被端 赌资21亿元均进入第三方支付后“漂白”