分区表的导入导出 expdp&impdp Oracle 11.2.0.4

2023-05-16

分区表的导入导出


数据库版本:

Oracle 11.2.0.4


expdp  导出 schema 。
当前有两个分区表
TABLE_NAME PARTITION_NAME TABLESPACE_NAME
------------------------------ ------------------------------ ------------------------------
TABLE1 SYS_P57 NEW
TABLE1 SYS_P66NEW
TABLE2 T_TEST_201503 T3
TABLE2 T_TEST_MAX T
TABLE2 T_TEST_201510 T4
TABLE2 T_TEST_201412 T2
TABLE2 T_TEST_201406 T1
21 rows selected.
SQL> l
  1* select TABLE_NAME,PARTITION_NAME,TABLESPACE_NAME from USER_TAB_PARTITIONS order by table_name

  
当前有两个分区表
table1 是创建在一个表空间中的分区表,有多个分区。
table2 是将有多个分区表空间的分区表,多个分区对应多个表空间。


涉及的表空间
new、T、T1、T2、T3、T4
涉及的用户
new


/**********对new用户进行导出,再远端数据库中导入  schema level

create directory EXPDP as '/backup/expdp';
grant read,write on directory EXPDP to system;

导出整个 new schema:
export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
expdp system/oracle  directory=EXPDP schemas=new dumpfile=20151228expnew.dmp logfile=20151228expnew.log
expdp system/oracle  directory=EXPDP schemas=new dumpfile=20151228expnewtab3.dmp logfile=20151228expnewtab3.log

. . exported "NEW"."PF_MEMBER_BANKCARD"                      0 KB       0 rows
. . exported "NEW"."PF_MEMBER_CORPORATION"                   0 KB       0 rows
. . exported "NEW"."PF_MEMBER_LINKINFO"                      0 KB       0 rows
. . exported "NEW"."TABLE2":"T_TEST_201503"                  0 KB       0 rows
Master table "SYSTEM"."SYS_EXPORT_SCHEMA_01" successfully loaded/unloaded
******************************************************************************
Dump file set for SYSTEM.SYS_EXPORT_SCHEMA_01 is:
  /backup/expdp/20151228expnew.dmp
Job "SYSTEM"."SYS_EXPORT_SCHEMA_01" successfully completed at Mon Dec 28 10:25:40 2015 elapsed 0 00:01:21


目标库导入new schema:
create directory EXPDP as '/backup/expdp';
grant read,write on directory EXPDP to system;
export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK

impdp system/oracle  directory=EXPDP dumpfile=20151228expnew.dmp schemas=new remap_schema=new:demo remap_tablespace=new:demo logfile=20151228expnew.log 


没有创建table2所需要的表空间的时候 报错:
[oracle@primary ~]$ export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
[oracle@primary ~]$ impdp system/oracle  directory=EXPDP dumpfile=20151228expnew.dmp schemas=new remap_schema=new:demo remap_tablespace=new:demo logfile=20151228expnew.log

ORA-39171: Job is experiencing a resumable wait.
ORA-01658: unable to create INITIAL extent for segment in tablespace DEMO
ORA-39083: Object type TABLE:"DEMO"."TABLE2" failed to create with error:
ORA-00959: tablespace 'T1' does not exist
Failing sql is:
CREATE TABLE "DEMO"."TABLE2" ("TABLE_ID" NUMBER(8,0), "SUB_DATE" DATE, "VALUE" NUMBER(8,0)) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255  STORAGE( BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT) TABLESPACE "DEMO"  PARTITION BY RANGE ("SUB_DATE")  (PARTITION "T_TEST_201406"  VALUES LESS THAN (TO_DATE(' 2014-06-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALEN
Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA
. . imported "DEMO"."PF_AGREEMENT"                           0 KB       0 rows
. . imported "DEMO"."PF_MEMBER_BANKCARD"                     0 KB       0 rows
. . imported "DEMO"."PF_MEMBER_CORPORATION"                  0 KB       0 rows
. . imported "DEMO"."PF_MEMBER_LINKINFO"                     0 KB       0 rows
Job "SYSTEM"."SYS_IMPORT_SCHEMA_01" completed with 5 error(s) at Mon Dec 28 10:55:08 2015 elapsed 0 00:07:31

因为 没有对应的表空间,所以导入失败。
SQL> select * from table1;
  TABLE_ID SUB_DATE     VALUE
---------- ------------ ----------
1 01-APR-14 11
1 01-MAY-14 11
1 01-JUN-14 11
1 01-JUL-14 11
SQL> select * from table2;
select * from table2
              *
ERROR at line 1:
ORA-00942: table or view does not exist

换个方法试试 将多个表空间的内容 导入到一个表空间。适用于 一个scheman中有多个表,分布在不同的表空间中,最终汇总到一个表空间。
参考:
impdp ctais3/oracle DIRECTORY=DATA_PUMP_DIR dumpfile=ctais2.dmp remap_schema=ctais2:ctais3 remap_tablespace='(EXAMPLE:ZHANGQIAOC,USERS:ZHANGQIAOC)'

impdp system/oracle  directory=EXPDP dumpfile=20151228expnew.dmp schemas=new remap_schema=new:demo remap_tablespace='new:demo,T:demo,T1:demo,T2:demo,T3:demo,T4:demo' logfile=20151228expnew.log

drop user demo cascade;
create user demo identified by demo default tablespace demo;

[oracle@primary ~]$ impdp system/oracle  directory=EXPDP dumpfile=20151228expnew.dmp schemas=new remap_schema=new:demo remap_tablespace='new:demo,T:demo,T1:demo,T2:demo,T3:demo,T4:demo' logfile=20151228expnew.log
Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA
. . imported "DEMO"."PF_AGREEMENT"                           0 KB       0 rows
. . imported "DEMO"."PF_MEMBER_BANKCARD"                     0 KB       0 rows
. . imported "DEMO"."PF_MEMBER_CORPORATION"                  0 KB       0 rows
. . imported "DEMO"."PF_MEMBER_LINKINFO"                     0 KB       0 rows
. . imported "DEMO"."TABLE2":"T_TEST_201503"                 0 KB       0 rows
Processing object type SCHEMA_EXPORT/TABLE/COMMENT
ORA-39082: Object type ALTER_PROCEDURE:"DEMO"."P_BALANCE_ONLINE_EXPORT" created with compilation warnings
ORA-39082: Object type ALTER_PROCEDURE:"DEMO"."P_CARD_ENCRYPT" created with compilation warnings
Job "SYSTEM"."SYS_IMPORT_SCHEMA_01" completed with 3 error(s) at Mon Dec 28 11:02:12 2015 elapsed 0 00:00:18

这么 调整之后,就可以将多个表空间的内容导入到一个表空间中了。

总结:
如果原schema中 包含了分区表,在进行导出的时候,是可以正常导出的。
使用 schemas=new remap_schema=new:demo remap_tablespace='new:demo,T:demo,T1:demo,T2:demo,T3:demo,T4:demo' 可以将一个schema中分布在不同多个表空间中的表 对应到新的schema下的 一个表空间中。
建议,在进行导出之前,最好先查一下,需要导出的schema中是否有分区表:
select table_name,PARTITION_NAME,TABLESPACE_NAME from USER_TAB_PARTITIONS order by table_name;
建议:在进行导入之前,如果确定包含分区表,最好是创建根之前对象的表空间一样名称的表空间。
如果不创建,或者创建对应表空间的话,使用
remap_tablespace='new:demo,T:T_new,T1:T1_new,T2:T2_new,T3:T3_new,T4:T4_new' 方式来对应---创建后依然是分区表
如果加上  partition_options=merge 选项后 变成了一个普通表


/**********分区表的导出 table level:
导出整个表
export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
expdp system/oracle DIRECTORY=EXPDP DUMPFILE=table2full.dmp TABLES=new.table2 logfile=table2full.log tables参数格式为user.table
导出一个分区
expdp system/oracle DIRECTORY=EXPDP DUMPFILE=table2one.dmp TABLES='new.table2:T_TEST_201510' logfile=table2one.log
导出多个分区
expdp system/oracle DIRECTORY=EXPDP DUMPFILE=table2some.dmp TABLES='new.table2:T_TEST_201510,new.table2:T_TEST_201412,new.table2:T_TEST_201503' logfile=table2some.log
expdp system/oracle DIRECTORY=EXPDP DUMPFILE=table2someo.dmp TABLES='new.table2:T_%' logfile=table2someo.log    使用通配符 跟exp imp的用法一致
导出部分数据
select * from table2  where to_char(SUB_DATE,'YYYY')>2014;
expdp system/oracle DIRECTORY=EXPDP DUMPFILE=table2data.dmp TABLES='new.table2' logfile=table2data.log query=\"where to_char\(SUB_DATE,\'YYYY\'\)\>2014\"


/**********Impdp 导入 schemas level:
如果分区表的表空间不存在
impdp system/oracle  directory=EXPDP dumpfile=20151228expnew.dmp schemas=new remap_schema=new:demo remap_tablespace=new:demo logfile=20151228expnew.log 会不导入该表,其他表可以导入
如果目标库上分区表的表空间 跟 源数据库上分区表的名称 创建的一致
impdp system/oracle  directory=EXPDP dumpfile=20151228expnew.dmp schemas=new remap_schema=new:demo remap_tablespace=new:demo logfile=20151228expnew.log  可以全部导入
将分区表聚合到一个表空间
impdp system/oracle  directory=EXPDP dumpfile=20151228expnew.dmp schemas=new remap_schema=new:demo remap_tablespace='new:demo,T:demo,T1:demo,T2:demo,T3:demo,T4:demo' logfile=20151228expnew.log


/**********impdp 导入分区表 table level:
分区表不存在
drop table table2 purge;
impdp system/oracle  directory=EXPDP dumpfile=20151228expnew.dmp schemas=new remap_schema=new:demo remap_tablespace=new:demo tables='new.table2' logfile=20151228impnew.table2.log

[oracle@primary ~]$ impdp system/oracle  directory=EXPDP dumpfile=20151228expnew.dmp schemas=new remap_schema=new:demo remap_tablespace=new:demo tables=table2 logfile=20151228impnew.table2.log
Import: Release 11.2.0.4.0 - Production on Mon Dec 28 13:02:36 2015
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, Automatic Storage Management, OLAP, Data Mining
and Real Application Testing options
UDI-00010: multiple job modes requested, schema and tables.
不支持 schemas 和 tables 同时存在

这样解决
源分区表 聚合到一个表空间
impdp system/oracle  directory=EXPDP dumpfile=20151228expnew.dmp remap_schema=new:demo remap_tablespace='new:demo,T:demo,T1:demo,T2:demo,T3:demo,T4:demo' tables=new.table2 logfile=20151228impnew.table2.log
说明 不设置参数partition_options 这样聚合之后,demo.table2 依然是一个分区表,只不过所有的数据都在一个表空间中。partition_options 默认是none的。

impdp system/oracle  directory=EXPDP dumpfile=20151228expnew.dmp remap_schema=new:demo remap_tablespace='new:demo,T:demo,T1:demo,T2:demo,T3:demo,T4:demo' tables=new.table2 partition_options=merge  logfile=20151228impnew.table2.log
说明 加入参数 partition_options=merge 选项后demo.table2 变成了一个普通表。


补充
partition_options=departition 这个参数是将各个分区 变成一个新的表。
impdp system/oracle  directory=EXPDP dumpfile=20151228expnew.dmp remap_schema=new:demo remap_tablespace='new:demo,T:demo,T1:demo,T2:demo,T3:demo,T4:demo' tables=new.table2 partition_options=departition  logfile=20151228impnew.table2.log
SQL> select table_name from user_tables;
TABLE_NAME
------------------------------
TABLE2_T_TEST_MAX
TABLE2_T_TEST_201510
TABLE2_T_TEST_201503
TABLE2_T_TEST_201412
TABLE2_T_TEST_201406

源分区表 和 目标分区表 相同表空间
1、先创建 表空间
查看分区表空间的对象关系 使用如下语句 在源数据库上查询:
select TABLE_NAME,PARTITION_NAME,TABLESPACE_NAME from USER_TAB_PARTITIONS order by table_name;
注意,分区表所依赖的表空间 并不单单指的是 分区的表空间,还包含 那个母表的表空间。
创建语句
##create tablespace new datafile '+DATA' size 200M; -----本例中,将new 表空间 remap_tablespace 到demo表空间中
create tablespace T datafile '+DATA' size 20M;
create tablespace T1 datafile '+DATA' size 20M;
create tablespace T2 datafile '+DATA' size 20M;
create tablespace T3 datafile '+DATA' size 20M;
create tablespace T4 datafile '+DATA' size 20M;
2、创建分区表(11g可不创建)
SELECT DBMS_METADATA.GET_DDL('TABLE',u.table_name) FROM USER_TABLES u where u.table_name='&name'; 获得DDL创建 需要先创建表空间
或者
从dump文件中获得 biao table2的DDL语句
impdp system/oracle directory=EXPDP dumpfile=20151228expnew.dmp sqlfile=EXPDP:table2_ddl.sql tables=new.table2
3、导入表
impdp system/oracle  directory=EXPDP dumpfile=20151228expnew.dmp remap_schema=new:demo remap_tablespace=new:demo tables=new.table2 logfile=20151228impnew.table2_sametbs.log

源分区表 和 目标分区表 不同表空间
1、先创建 表空间
创建语句
##create tablespace new datafile '+DATA' size 200M; -----本例中,将new 表空间 remap_tablespace 到demo表空间中
create tablespace TN datafile '+DATA' size 20M;
create tablespace TN1 datafile '+DATA' size 20M;
create tablespace TN2 datafile '+DATA' size 20M;
create tablespace TN3 datafile '+DATA' size 20M;
create tablespace TN4 datafile '+DATA' size 20M;
2、创建分区表(11g可不创建)
SELECT DBMS_METADATA.GET_DDL('TABLE',u.table_name) FROM USER_TABLES u where u.table_name='&name'; 获得DDL创建 需要先创建表空间
或者
从dump文件中获得 biao table2的DDL语句
impdp system/oracle directory=EXPDP dumpfile=20151228expnew.dmp sqlfile=EXPDP:table2_ddl.sql tables=new.table2
3、导入表
impdp system/oracle  directory=EXPDP dumpfile=20151228expnew.dmp remap_schema=new:demo remap_tablespace='new:demo,T:TN,T1:TN1,T2:TN2,T3:TN3,T4:TN4' tables=new.table2 logfile=20151228impnew.table2_sametbs_n.log

如果只是导 入分区的话 
impdp system/oracle  directory=EXPDP dumpfile=20151228expnew.dmp remap_schema=new:demo remap_tablespace='new:demo,T:TN,T1:TN1,T2:TN2,T3:TN3,T4:TN4' tables='new.table2:T_TEST_201503,new.table2:T_TEST_201412' logfile=20151228impnew.table2_pn.log
impdp system/oracle  directory=EXPDP dumpfile=20151228expnew.dmp remap_schema=new:demo remap_tablespace='new:demo,T:TN,T1:TN1,T2:TN2,T3:TN3,T4:TN4' tables='new.table2:T_TEST_%' logfile=20151228impnew.table2_pn.log
impdp system/oracle  directory=EXPDP dumpfile=20151228expnew.dmp remap_schema=new:demo remap_tablespace=new:demo tables='new.table2:T_TEST_%' logfile=20151228impnew.table2_sametbs.log


/****************/将原来在一个表空间中的分区表,导入为每个分区一个表空间的表,目标也在一个新的表空间中
原来表table3 
SQL> select * from table3;
  TABLE_ID SUB_DATE     VALUE
---------- ------------ ----------
1 01-APR-14 11
1 01-MAY-14 11
1 01-JUN-14 11
1 01-JUL-14 11
1 01-AUG-14 11
1 01-AUG-14 11
1 01-SEP-14 11
1 01-OCT-14 11
1 01-NOV-14 11
1 01-JUN-15 11
1 01-JUL-15 11
1 01-AUG-15 11
1 01-SEP-15 11
1 01-OCT-15 11
1 01-NOV-15 11
1 01-DEC-15 11
1 01-JUN-16 11
 
目的 将table3迁移成分区表
方案一  手动先创建 目标分区表(表空间是必须要先创建好的)
1、创建一个分区表 demo.table3 on 目标库
select dbms_metadata.get_ddl('TABLE','TABLE3','DEMO') from dual; 

##create tablespace demo datafile '+DATA' size 200M; -----本例中,将 demo 表空间为默认表空间 不需要再次创建
create tablespace T datafile '+DATA' size 20M;
create tablespace T1 datafile '+DATA' size 20M;
create tablespace T2 datafile '+DATA' size 20M;
create tablespace T3 datafile '+DATA' size 20M;
create tablespace T4 datafile '+DATA' size 20M;

conn demo/demo
create table table3 (
   TABLE_ID NUMBER(8),
   SUB_DATE DATE,
   VALUE NUMBER(8)
)
PARTITION BY RANGE (SUB_DATE)
(
  PARTITION t_test_201406 VALUES LESS THAN (TO_DATE('2014-06-01 00:00:00','yyyy-mm-ddhh24:mi:ss')) TABLESPACE T1,
  PARTITION t_test_201412 VALUES LESS THAN (TO_DATE('2014-12-01 00:00:00','yyyy-mm-ddhh24:mi:ss')) TABLESPACE T2,
  PARTITION t_test_201503 VALUES LESS THAN (TO_DATE('2015-03-01 00:00:00','yyyy-mm-ddhh24:mi:ss')) TABLESPACE T3,
  PARTITION t_test_201510 VALUES LESS THAN (TO_DATE('2015-10-01 00:00:00','yyyy-mm-ddhh24:mi:ss')) TABLESPACE T4,
  PARTITION t_test_max   VALUES LESS THAN (MAXVALUE) TABLESPACE T
) ;
----注意 parttion是在 T%表空上的,但是 table3是在DEMO表空间中的。 可以创建新的分区名称 以及重新定义表空间的名称

2、导入
impdp system/oracle  directory=EXPDP dumpfile=20151228expnewtab3.dmp remap_schema=new:demo  tables='new.table3' table_exists_action=append logfile=20151228impnew.table3.log

[oracle@primary expdp]$ impdp system/oracle  directory=EXPDP dumpfile=20151228expnewtab3.dmp remap_schema=new:demo  tables='new.table3' table_exists_action=append logfile=20151228impnew.table3.log

Import: Release 11.2.0.4.0 - Production on Mon Dec 28 15:11:02 2015
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, Automatic Storage Management, OLAP, Data Mining
and Real Application Testing options
Master table "SYSTEM"."SYS_IMPORT_TABLE_01" successfully loaded/unloaded
Starting "SYSTEM"."SYS_IMPORT_TABLE_01":  system/******** directory=EXPDP dumpfile=20151228expnewtab3.dmp remap_schema=new:demo tables=new.table3 table_exists_action=append logfile=20151228impnew.table3.log 
Processing object type SCHEMA_EXPORT/TABLE/TABLE
Table "DEMO"."TABLE3" exists. Data will be appended to existing table but all dependent metadata will be skipped due to table_exists_action of append
Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA
. . imported "DEMO"."TABLE3"                             6.195 KB      17 rows
Job "SYSTEM"."SYS_IMPORT_TABLE_01" successfully completed at Mon Dec 28 15:11:08 2015 elapsed 0 00:00:05

select * from table3 PARTITION(t_test_201406);
SQL> select * from table3 PARTITION(t_test_201406);
  TABLE_ID SUB_DATE     VALUE
---------- ------------ ----------
1 01-APR-14 11
1 01-MAY-14 11

3、导入到不同的表名称中
(1)创建表
create table tableN (
   TABLE_ID NUMBER(8),
   SUB_DATE DATE,
   VALUE NUMBER(8)
)
PARTITION BY RANGE (SUB_DATE)
(
  PARTITION t_test_1 VALUES LESS THAN (TO_DATE('2014-06-01 00:00:00','yyyy-mm-ddhh24:mi:ss')) TABLESPACE T1,
  PARTITION t_test_2 VALUES LESS THAN (TO_DATE('2014-12-01 00:00:00','yyyy-mm-ddhh24:mi:ss')) TABLESPACE T2,
  PARTITION t_test_3 VALUES LESS THAN (TO_DATE('2015-03-01 00:00:00','yyyy-mm-ddhh24:mi:ss')) TABLESPACE T3,
  PARTITION t_test_4 VALUES LESS THAN (TO_DATE('2015-10-01 00:00:00','yyyy-mm-ddhh24:mi:ss')) TABLESPACE T4,
  PARTITION t_test_max   VALUES LESS THAN (MAXVALUE) TABLESPACE T
) ;

(2) 导入
impdp system/oracle  directory=EXPDP dumpfile=20151228expnewtab3.dmp remap_schema=new:demo tables='new.table3' remap_tablespace='new:demo' remap_table='new.table3:tablen'  table_exists_action=append logfile=20151228impnew.table3.log
[oracle@primary expdp]$ impdp system/oracle  directory=EXPDP dumpfile=20151228expnewtab3.dmp remap_schema=new:demo tables='new.table3' remap_tablespace='new:demo' remap_table='new.table3:tablen'  table_exists_action=append logfile=20151228impnew.table3.log

Import: Release 11.2.0.4.0 - Production on Mon Dec 28 15:33:42 2015
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, Automatic Storage Management, OLAP, Data Mining
and Real Application Testing options
Master table "SYSTEM"."SYS_IMPORT_TABLE_01" successfully loaded/unloaded
Starting "SYSTEM"."SYS_IMPORT_TABLE_01":  system/******** directory=EXPDP dumpfile=20151228expnewtab3.dmp remap_schema=new:demo tables=new.table3 remap_tablespace=new:demo remap_table=new.table3:tablen table_exists_action=append logfile=20151228impnew.table3.log 
Processing object type SCHEMA_EXPORT/TABLE/TABLE
Table "DEMO"."TABLEN" exists. Data will be appended to existing table but all dependent metadata will be skipped due to table_exists_action of append
Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA
. . imported "DEMO"."TABLEN"                             6.195 KB      17 rows
Job "SYSTEM"."SYS_IMPORT_TABLE_01" successfully completed at Mon Dec 28 15:33:44 2015 elapsed 0 00:00:02
注意 remap_table='new.table3:tablen'  这里 不要再tablen之前加用户名称,否则会创建 “username.tablen” 这样一个表

select * from tableN PARTITION(t_test_1);
SQL>  select * from tableN PARTITION(t_test_1);

  TABLE_ID SUB_DATE     VALUE
---------- ------------ ----------
1 01-APR-14 11
1 01-MAY-14 11
注意:
由于约束是系统名称,导致在执行REMAP_TABLE导入后,同样的约束在源表上重复建立


 
/**********impdp 分区表 追加:
1、按分区追加
清理分区:
alter table test truncate partiton a;
ALTER TABLE yourTable DROP PARTITION partionName1;
alter table table1 DROP PARTITION SYS_P41;

增加第一个分区
impdp system/oracle  directory=EXPDP dumpfile=20151228expnew.dmp remap_schema=new:demo remap_tablespace='new:demo'  tables='new.table1:P1' logfile=20151228impnew.table1_1.log

追加后面的分区
----impdp system/oracle  directory=EXPDP dumpfile=20151228expnew.dmp remap_schema=new:demo remap_tablespace='new:demo'  tables='new.table1:P1' table_exists_action=append参数 logfile=20151228impnew.table1_1.log
impdp system/oracle  directory=EXPDP dumpfile=20151228expnew.dmp remap_schema=new:demo remap_tablespace='new:demo'  tables='new.table1:SYS_P41'  table_exists_action=append参数 logfile=20151228impnew.table1_SYS_P41.log  切记,table_exists_action的参数 尽量不要使用replace 和 truncate
append 是为表增加数据;
truncate 是截断表,然后为其增加新数据;
replace  是删除已存在表,重新建表并追加数据。
或者
impdp system/oracle  directory=EXPDP dumpfile=20151228expnew.dmp remap_schema=new:demo remap_tablespace='new:demo'  tables='new.table1:SYS_P%'  table_exists_action=append参数 logfile=20151228impnew.table1_SYS_Pn.log 








参考:
exp/imp,expdp/impdp 与分区表有关的知识:使用exp -help 查看:
example: imp scott/tiger ignore=y tables=(emp,dept) full=n
               or tables=(t1:p1,t1:p2), if t1 is partitioned table
example: exp scott/tiger grants=y tables=(emp,dept,mgr)
               or tables=(t1:p1,t1:p2), if t1 is partitioned table
example: expdp scott/tiger dumpfile=scott.dmp directory=dmpdir schemas=scott   or tables=(t1:p1,t1:p2), if t1 is partitioned table
example: impdp scott/tiger directory=dmpdir dumpfile=scott.dmp


从转储文件中提取DDL。
如:impdp system/oracle directory=EXPDP dumpfile=20151228expnew.dmp sqlfile=EXPDP:table22.sql schemas=new 就是指将属于 new模式的所有DDL写入位于EXPDP的table22.sql文件中.
Expdp导出分区表的数据文件再Impdp导入到没分区的表的操作方法


 Article_Detail是个按时间的分区表:


导出的Bat如下:假设这个表有四个分区,且每个分区的NUM_ROWs至少有20万记录,导出参数tables=Article_Detail 表示每个分区都会导出20万条记录,实则导出的记录为80万。
expdp test/1234@orcl_test query=article_detail:\"where rownum<=200000 order by Article_Detail_ID desc\" tables=Article_Detail directory=TEST_DUMP_DIR dumpfile=Article_Detail_20W.dmp logfile=Article_Detail_20W.log compression=DATA_ONLY  content=DATA_ONLY parallel=2
 
导入:从分区表导出的文件里导入到非分区表,在导入的批处理里要有partition_options参数,partition_options=merge表示将四个分区的数据合并在一起。因为分区表中对应多个表空间,所以要remap_tablespace一下,导入脚本如下:
impdp test_2/1234@orcl_test2 directory=TEST_DUMP_DIR remap_schema=test:test_2 dumpfile=Article_Detail_20W.dmp logfile=Impdp_Article_Detail_20W.log table_exists_action=APPEND data_options=SKIP_CONSTRAINT_ERRORS parallel=2 Exclude=Trigger partition_options=merge   
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

分区表的导入导出 expdp&impdp Oracle 11.2.0.4 的相关文章

  • 使用Git为每个项目配置独立的用户名和邮箱

    使用Git为每个项目配置独立的用户名和邮箱 平时在开发的过程中 xff0c 用到git时 xff0c 要做一些特殊的配置 xff0c 例如自己公司内网https的SSL证书未经过第三方机构签署 xff0c 直接操作Git就会报错 xff0c
  • 电脑重装系统后文件还能恢复吗?2个方法助你还原文件

    电脑重装系统后文件还能恢复吗 xff1f 此时可能你面临一个难题 xff1a 已经重装了电脑 xff0c 但是发现丢失的问题 实际上 xff0c 一般当电脑出现运行缓慢 xff0c 或者是电脑系统出现故障无法修复的时候 xff0c 大家都会
  • C盘重装还能恢复以前文件嘛,重装C盘数据备份清单

    重装系统主要是对C盘的重装 xff0c 也就是对C盘的格式化 xff0c 电脑安装系统的位置是C盘 xff0c 常见的重装方法只影响C盘而不会丢失其他盘的数据 那么C盘重装还能恢复以前的文件嘛 xff1f 重装C盘时什么文件必须备份呢 xf
  • HTML Parsing Error:Unable to modify the parent container element before the child element is closed

    一 又涨见识了 IE8报下面错误 xff0c 而且是我的机器不报 xff0c 同事的机器报 xff0c 试了4台 xff0c 两个报 xff0c 两个不报 xff0c IE版本都一样 xff0c 没想明白 解决 xff1a 1 查看是否有未
  • 架构师必须学会的几种 UML图

    文章目录 一 UML 是什么定义作用 二 UML 画图的工具推荐三 UML 类图中的关系1 泛化 继承 2 实现 xff08 Realization xff09 3 关联 xff08 Association 4 聚合 xff08 Aggre
  • 算法:如何实现两个大数相加

    文章目录 问题要求思路代码实现 问题 实现两个很大很大的数相加 xff0c 求出它们的和 要求 1 是整数 xff1b 2 两个数无限大 xff0c long 都装不下 xff1b 3 不能用 BigInteger xff1b 4 不能用任
  • 关于Android 未来开发的方向探讨

    文章目录 背景Anroid 应用开发工程师技能参考Android 基础设施建设技能参考Android 逆向开发工程师技能参考Android Framework工程师技能参考 xff08 车载系统 系统开发方向 xff09 Android 性
  • Git Commit Message 规范实践

    文章目录 背景示例FeatureBugRefactorDocsTestStyleChore 每个Merge Request只有一个Commit小结附录 背景 本文总结了项目实践中的 Commit Message 规范 任何一笔提交都是有原因
  • github push 报错的问题记录

    文章目录 背景解决办法示例 背景 当 git 执行 git push xff08 origin origin master xff09 后出现错误提示 xff1a git push origin origin master Password
  • Mac 平台 Android FFmpeg 编译与集成实践

    文章目录 FFmpeg 是什么为什么要学 FFmpeg 开发FFmpeg 编译1 编译环境准备2 FFmpeg 环境配置3 完整的脚本4 FQA 编译小结在Android Studio 中的集成集成问题记录写在最后 FFmpeg 是什么 F
  • 音频中文件大小计算公式(转)

    声卡对声音的处理质量可以用三个基本参数来衡量 xff0c 即采样频率 采样位数和声道数 采样频率是指单位时间内的采样次数 采样频率越大 xff0c 采样点之间的间隔就越小 xff0c 数字化后得到的声音就越逼真 xff0c 但相应的数据量就
  • 「设计模式」六大原则之一:单一职责小结

    文章目录 1 单一职责原则定义2 如何理解单一职责原则 xff08 SRP xff09 xff1f 3 如何判断类的职责是否足够单一 xff1f 4 类的职责是否设计得越单一越好 xff1f 5 应用体现6 应用示例18 应用示例2 xff
  • 「设计模式」六大原则之二:开闭职责小结

    文章目录 1 开闭原则定义2 如何理解 对扩展开放 对修改关闭 xff1f 3 如何做到 对扩展开放 修改关闭 xff1f 4 如何在项目中灵活应用开闭原则 xff1f 5 示例 xff1a 6 小结 xff1a 设计模式 六大原则系列链接
  • 「设计模式」六大原则之三:里氏替换原则小结

    文章目录 1 里式替换原则定义2 举例说明示例1 xff1a 示例2 xff1a 3 哪些代码明显违背了 LSP xff1f 子类违背父类声明要实现的功能子类违背父类对输入 输出 异常的约定子类违背父类注释中所罗列的任何特殊说明开发 Tip
  • 「设计模式」六大原则之四:接口隔离原则小结

    文章目录 1 接口隔离原则定义2 如何理解3 接口隔离原则与单一职责原则的区别2 举例说明4 小结 设计模式 六大原则系列链接 设计模式 六大原则之一 xff1a 单一职责小结 设计模式 六大原则之二 xff1a 开闭职责小结 设计模式 六
  • 「设计模式」六大原则之五:依赖倒置原则小结

    文章目录 1 依赖倒置原则 xff08 DIP xff09 定义4 DIP举例说明2 如何理解控制反转 xff08 IOC xff09 3 如何理解依赖注入 xff08 DI xff09 4 小结 设计模式 六大原则系列链接 设计模式 六大
  • 「设计模式」六大原则之六:最小知识原则小结

    文章目录 1 最小知识原则 xff08 LOD xff09 定义2 什么是 高内聚 呢3 什么是 松耦合 xff1f 4 应用举例 设计模式 六大原则系列链接 设计模式 六大原则之一 xff1a 单一职责小结 设计模式 六大原则之二 xff
  • Android NDK 中堆栈日志 add2line 的分析实践

    文章目录 目的常用的辅助工具分析步骤参考 目的 Android NDK 中出现的 crash 日志分析定位 xff0c 使用 addr2line 对库中定位so 动态库崩溃位置 xff0c 定位到某个函数的具体的代码行 常用的辅助工具 ad
  • Android 中关于 FileObserver类监听文件状态的实践

    文章目录 需求背景走进源码实现示例参考 需求背景 当某一个目录的文件发生变化 xff08 创建 修改 删除 移动 xff09 时 xff0c 需要给一个回调事件给其他端调用 其他场景 xff1a 阅后即焚等等 比如在 Android 的 V
  • Android10 系统 Framework 中定制实现开关机动画实践

    文章目录 写在前面 需求背景 主要问题 接口测试 权限问题对比测试 最后实现方案 其他问题 总结 写在前面 本文主要记录了在Android 10 系统 定制开关机动画时遇到的权限 读写 问题以用开关机动画资源的流程 文件要求等问题 涉及知识

随机推荐