oracle分区表导入数据,Oracle 分区表数据的导入与导出(2)
5.导入整个表
SQL> truncate table tb_pt;--首先truncate整个表
Table truncated.
SQL>ho imp scott/tiger tables=tb_pt file='/u02/dmp/tb_pt.dmp' ignore=y indexes=y
Export: Release 11.2.0.1.0 - Production on Wed Mar 9 13:57:10 2011
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, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing o
Export file created by EXPORT:V11.02.00 via conventional path
import done in US7ASCII character set and AL16UTF16 NCHAR character set
import server uses ZHS16GBK character set (possible charset conversion)
. importing SCOTT's objects into SCOTT
. importing SCOTT's objects into SCOTT
. . importing partition"TB_PT":"SAL_11"298 rows imported
. . importing partition"TB_PT":"SAL_12"366 rows imported
. . importing partition"TB_PT":"SAL_13" 365 rows imported
. . importing partition"TB_PT":"SAL_14"365 rows imported
. . importing partition"TB_PT":"SAL_15"365 rows imported
. . importing partition"TB_PT":"SAL_16"366 rows imported
. . importing partition"TB_PT":"SAL_OTHER"2875 rows imported
Import terminated successfully without warnings.
SQL> select count(1) from tb_pt partition(sal_other);
COUNT(1)
----------
2875
四、使用expdp/impdb来实现分区表的导入导出
1.查看导入导出的目录设置
SQL> select directory_name,directory_path from dba_directories where directory_name='DMP';
DIRECTORY_NAMEDIRECTORY_PATH
------------------------------ ------------------------------------------------------------
DMP/u02/dmp
2.为分区表创建一个本地索引
create index tb_pt_local_idx
on tb_pt(sal_id)
local
(partition local1,
partition local2,
partition local3,
partition local4,
partition local5,
partition local6,
partition local7)
;
3.导出整个表
[oracle@node1 ~]$expdp scott/tiger directory=dmp dumpfile=tb_pt.dmp logfile=tb_pb.log tables=tb_pt parallel=3
Export: Release 11.2.0.1.0 - Production on Wed Mar 9 14:04:28 2011
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, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options
Starting "SCOTT"."SYS_EXPORT_TABLE_01":scott/******** directory=dmp dumpfile=tb_pt.dmp logfile=tb_pb.log tables=
tb_pt parallel=3
Estimate in progress using BLOCKS method...
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 512 KB
. . exported "SCOTT"."TB_PT":"SAL_OTHER"71.63 KB2875 rows
. . exported "SCOTT"."TB_PT":"SAL_11"12.54 KB298 rows
. . exported "SCOTT"."TB_PT":"SAL_12"14.22 KB366 rows
. . exported "SCOTT"."TB_PT":"SAL_13"14.18 KB365 rows
. . exported "SCOTT"."TB_PT":"SAL_14"14.18 KB365 rows
. . exported "SCOTT"."TB_PT":"SAL_15"14.19 KB365 rows
. . exported "SCOTT"."TB_PT":"SAL_16"14.23 KB366 rows
Processing object type TABLE_EXPORT/TABLE/TABLE
Processing object type TABLE_EXPORT/TABLE/GRANT/OWNER_GRANT/OBJECT_GRANT
Processing object type TABLE_EXPORT/TABLE/INDEX/INDEX
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_01" successfully loaded/unloaded
******************************************************************************
Dump file set for SCOTT.SYS_EXPORT_TABLE_01 is:
/u02/dmp/tb_pt.dmp
Job "SCOTT"."SYS_EXPORT_TABLE_01" successfully completed at 14:04:51
4.导出多个分区
[oracle@node1 ~]$ expdp scott/tiger directory=dmp dumpfile=tb_pts.dmp logfile=tb_pt.log /
> tables=(tb_pt:sal_16,tb_pt:sal_other) parallel=2
Export: Release 11.2.0.1.0 - Production on Wed Mar 9 14:08:06 2011
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, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options
Starting "SCOTT"."SYS_EXPORT_TABLE_01":scott/******** directory=dmp dumpfile=tb_pts.dmp logfile=tb_pt.log
tables=(tb_pt:sal_16,tb_pt:sal_other) parallel=2--*/
Estimate in progress using BLOCKS method...
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 192 KB
. . exported "SCOTT"."TB_PT":"SAL_OTHER"71.63 KB2875 rows
. . exported "SCOTT"."TB_PT":"SAL_16"14.23 KB366 rows
Processing object type TABLE_EXPORT/TABLE/TABLE
Processing object type TABLE_EXPORT/TABLE/GRANT/OWNER_GRANT/OBJECT_GRANT
Processing object type TABLE_EXPORT/TABLE/INDEX/INDEX
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_01" successfully loaded/unloaded
******************************************************************************
Dump file set for SCOTT.SYS_EXPORT_TABLE_01 is:
/u02/dmp/tb_pts.dmp
Job "SCOTT"."SYS_EXPORT_TABLE_01" successfully completed at 14:08:17
5.截断分区sal_other
SQL> alter table tb_pt truncate partition(sal_other);
Table truncated.
SQL> select count(*) from tb_pt partition(sal_other);
COUNT(*)
----------
0
SQL> select index_name,status,partitioned from dba_indexes where table_name='TB_PT'; --查看索引的状态,TB_PT_IND1不可用
INDEX_NAMESTATUSPAR
------------------------------ -------- ---
TB_PT_IND1UNUSABLE NO
TB_PT_LOCAL_IDXN/AYES
SQL> select index_name ,partition_name, status from dba_ind_partitions where index_owner='SCOTT';
INDEX_NAMEPARTITION_NAMESTATUS
------------------------------ ------------------------------ --------
TB_PT_LOCAL_IDXLOCAL1USABLE
TB_PT_LOCAL_IDXLOCAL2USABLE
TB_PT_LOCAL_IDXLOCAL3USABLE
TB_PT_LOCAL_IDXLOCAL4USABLE
TB_PT_LOCAL_IDXLOCAL5USABLE
TB_PT_LOCAL_IDXLOCAL6USABLE
TB_PT_LOCAL_IDXLOCAL7USABLE
6.导入单个分区
[oracle@node1 ~]$impdp scott/tiger directory=dmp dumpfile=tb_pts.dmp logfile=tb_pt_imp.log /
> tables=tb_pt:sal_other skip_unusable_indexes=y table_exists_action=replace
Import: Release 11.2.0.1.0 - Production on Wed Mar 9 14:13:28 2011
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, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options
Master table "SCOTT"."SYS_IMPORT_TABLE_01" successfully loaded/unloaded
Starting "SCOTT"."SYS_IMPORT_TABLE_01":scott/******** directory=dmp dumpfile=tb_pts.dmp logfile=tb_pt_imp.log
tables=tb_pt:sal_other skip_unusable_indexes=y table_exists_action=replace--*/
Processing object type TABLE_EXPORT/TABLE/TABLE
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
. . imported "SCOTT"."TB_PT":"SAL_OTHER"71.63 KB2875 rows
Processing object type TABLE_EXPORT/TABLE/GRANT/OWNER_GRANT/OBJECT_GRANT
Processing object type TABLE_EXPORT/TABLE/INDEX/INDEX
Processing object type TABLE_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
Job "SCOTT"."SYS_IMPORT_TABLE_01" successfully completed at 14:13:33
SQL> select index_name,status,partitioned from dba_indexes where table_name='TB_PT';
INDEX_NAMESTATUSPAR
------------------------------ -------- ---
TB_PT_IND1VALIDNO
TB_PT_LOCAL_IDXN/AYES
从上面的导入情况可以看出,尽管执行了truncate partition,然而使用impdp导入工具,并且使用参数table_exists_action=replace
可以避免使用imp导入时唯一和主键索引需要重建的问题。注意,如果没有使用table_exists_action=replace参数,将会收到ORA-39151
错误,如下
ORA-39151: Table "SCOTT"."TB_PT" exists. All dependent metadata and data will be skipped due to
table_exists_action of skip
7.导入整个表
[oracle@node1 ~]$ impdp scott/tiger directory=dmp dumpfile=tb_pt.dmp logfile=tb_pt_fullimp.log /
> tables=tb_pt skip_unusable_indexes=y table_exists_action=replace
Import: Release 11.2.0.1.0 - Production on Wed Mar 9 14:17:35 2011
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, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options
Master table "SCOTT"."SYS_IMPORT_TABLE_01" successfully loaded/unloaded
Starting "SCOTT"."SYS_IMPORT_TABLE_01":scott/******** directory=dmp dumpfile=tb_pt.dmp logfile=tb_pt_fullimp.log
tables=tb_pt skip_unusable_indexes=y table_exists_action=replace--*/
Processing object type TABLE_EXPORT/TABLE/TABLE
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
. . imported "SCOTT"."TB_PT":"SAL_OTHER"71.63 KB2875 rows
. . imported "SCOTT"."TB_PT":"SAL_11"12.54 KB298 rows
. . imported "SCOTT"."TB_PT":"SAL_12"14.22 KB366 rows
. . imported "SCOTT"."TB_PT":"SAL_13"14.18 KB365 rows
. . imported "SCOTT"."TB_PT":"SAL_14"14.18 KB365 rows
. . imported "SCOTT"."TB_PT":"SAL_15"14.19 KB365 rows
. . imported "SCOTT"."TB_PT":"SAL_16"14.23 KB366 rows
Processing object type TABLE_EXPORT/TABLE/GRANT/OWNER_GRANT/OBJECT_GRANT
Processing object type TABLE_EXPORT/TABLE/INDEX/INDEX
Processing object type TABLE_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
Job "SCOTT"."SYS_IMPORT_TABLE_01" successfully completed at 14:17:40
五、参数skip_unusable_indexes的作用
SQL> show parameter skip
NAMETYPEVALUE
------------------------------------ ----------- ------------------------------
skip_unusable_indexesbooleanTRUE
该参数允许在导入分区数据时延迟对索引的处理,即先将数据导入,导入后再来重建索引分区。
在命令行导入中未指定导入参数skip_unusable_indexes时,则对于索引相关的问题,根据数据库初始化参数的值来确定。
在命令行导入中如果指定了参数skip_unusable_indexes时,则该参数的值优先于数据库初始化参数的设定值。
skip_unusable_indexes=y对unique index不起作用,因为此时的unique index扮演者constraint的作用,所以在insert数据时index必须被
更新。
对于单个分区导入时PK,unique index的处理,必须先重建索引然后进行导入。
使用impdp数据泵实现导入并使用参数table_exists_action=replace可以解决上述问题,即ORA-01502错误。
oracle分区表导入数据,Oracle 分区表数据的导入与导出(2)相关推荐
- oracle查看分区表的数据,ORACLE数据库查看分区表相关信息的方法
ORACLE数据库如何查看分区表的相关信息呢?不知道你有没有总结过这方面的知识.下面我们先创建两个表TEST. GPRS_CELLTOPVOL_WK来做实验,脚本如下: CREATE TABLE GP ...
- 使用Oracle 的 imp ,exp 命令实现数据的导入导出
本文对Oracle数据的导入导出 imp ,exp 两个命令进行了介绍, 并对其相应的参数进行了说明,然后通过一些示例进行演练,加深理解. 文章最后对运用这两个命令可能出现的问题(如权限不够,不同or ...
- oracle 导入流程,Oracle数据库(旧)空间数据表创建与数据导入流程说明V2.0
空间数据表创建与数据导入过程说明 1.打开命令符窗口(开始->运行->CMD),设置当前目录为存放.shp文件的目录. 2.确保当前目录下有SHP2SDO.EXE程序存在. 3.运行SHP ...
- 数据如何导入oracle数据库,如何用Oracle导入导出工具来实现Oracle数据库移植?
Oracle数据库作为目前市场的主流数据库之一,许多应用都在其上进行开发,由于Oracle数据库更新换代的原因和不同的应用程序提供商,可能会造成在一个单位的应用中存在Oracle的几种版本,如Orac ...
- oracle外部表导入,oracle 外部表导入时间日期类型数据
oracle 外部表导入时间日期类型数据以下文字资料是由(历史新知网www.lishixinzhi.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧! 建立外部表目录 create d ...
- oracle impdp导入实例,Oracle数据泵导入导出案例
Oracle数据库导入导出工具,可以使用exp/imp,但这是比较早期的工具.本文主要介绍数据泵expdp/impdp工具的使用. 建立数据泵目录 使用数据泵需要先建directory create ...
- 如何将sql数据导入到oracle数据库,将SQLServer的数据导入到Oracle数据库的方法-Oracle...
1.首先在SQL Server的电脑上安装Oracle,或者是操作的电脑上安装Oracle,如果没有,导出时会提示失败 2.打开SQL Server,右键点击要导出的数据库,选择"任务&qu ...
- oracle导入del数据文件,pl/sql,Oracle数据库中,不小心delete数据并递交后如何恢复被删数据...
用pl/sql developer导出表的数据时有三种方式:Oracle Export,Sql Insert,pl/sql developer 区别 导出数据到excel文件 excel数据导入到数据 ...
- hive sqoop 分区导入_利用oozie,执行sqoop action将DB2中的数据导入到hive分区表中
测试:利用oozie,执行sqoop action将DB2中的数据导入到hive分区表中. 需要注意的地方: 1,要添加hive.metastore.uris这个参数.否则无法将数据加载到hive表中 ...
最新文章
- 机器人导航两篇顶级会议论文解析
- 面试:字符串拼接,什么时候用StringBuilder?
- 怎么学JavaScript?
- 2.2.1 MySQL基本功能与参数文件管理
- 机器人在线“偷懒”怎么办?阿里研究出了这两套算法
- 【贪心】Radar Installation(poj 1328)
- ZeroMQ--使用jzmq进行编程
- C#开发笔记之18-如何用C#模拟(传统方法)发送Post请求或Get请求?
- SCCM 2012 R2 从入门到精通 Part8 软件部署
- 手持终端的时候应该有数据线
- 更改远程桌面默认端口3389及删除远程桌面连接历史记录
- 数字化底层逻辑揭秘!探寻地产工程行业发展新范式
- 我如何零基础转行成为一个自信的前端
- 计算机专用英语词汇1500词
- 用java写个记账本,融会贯通你的J2SE(一)java实战项目 Java项目
- 有 ABCD 四个人要在夜里过一座桥,他们通过这座桥分别需要耗时 1、2、5、10 分钟,现在只有一支手电,过桥时必须带有手电,并且同时最多只能两个人一起过桥。请问如何安排能够让四个人尽快都过桥。
- java生成图片二维码
- win10开启远程桌面连接的的一波三折——无法连接到远程计算机、你的凭据不工作
- js 实现浏览器下载视频2种方法
- Strace 解决性能问题案例一则
热门文章
- 谷歌采用神经网络驱动机器翻译,可离线翻译59种语言
- 水墨风格化matlab,调色进阶篇:如何调出浓水墨风格?
- c语言炉石传说算法设计,CCF-CSP题解 201609-3 炉石传说
- 2014美国大学计算机科学专业排名,2014年美国大学计算机科学专业排名.doc
- 别学AI了!90%的人编程能力差,其实都是输在了这点上!
- FFmpeg入门详解之111:RTSP协议2
- 动态规划问题——最长公共子序列问题
- html仪表盘模版,【Minton v1.0.0】管理后台仪表盘HTML5模板
- linux环境下ps命令行,Linux系统ps命令详解:查看正在运行的进程
- DYA9面向对象中--方法的重写