|
user_segments where segment_name='T1_INDX';
PARTITION_NAME TABLESPACE_NAME
------------------------------ ------------------------------
P1 TBS1_INDX
P2 TBS2_INDX
P3 TBS3_INDX
插入数据:
17:34:09 SYS@ prod >begin
17:34:26 2 for i in 1..3 loop
17:34:32 3 insert into scott.t1 select object_id*i,object_name from dba_objects where object_id <1000;
17:34:43 4 end loop;
17:34:51 5 commit;
17:34:57 6 end;
17:35:02 7 /
PL/SQL procedure successfully completed.
17:32:08 SCOTT@ prod >select count(*) from t1;
COUNT(*)
----------
2826
17:36:52 SCOTT@ prod >select 'p1',count(*) from t1 partition(p1)
17:37:42 2 union
17:37:47 3 select 'p2',count(*) from t1 partition(p2)
17:38:11 4 union
17:38:13 5 select 'p3',count(*) from t1 partition(p3);
'P1' COUNT(*)
-------------------------------- ----------
p1 1740
p2 774
p3 312
2、传输表空间
17:35:04 SYS@ prod >alter tablespace tbs1 read only;
Tablespace altered.
17:41:02 SYS@ prod >alter tablespace tbs1_indx read only;
Tablespace altered.
17:39:14 SYS@ prod >create directory tbs_dir as '/home/oracle/data';
Directory created.
17:40:30 SYS@ prod >grant read,write on directory tbs_dir to scott;
Grant succeeded.
[oracle@RH6 data]$ expdp system/oracle directory=tbs_dir dumpfile=p1.dmp transport_tablespaces=tbs1,tbs1_indx logfile=p1.log
Export: Release 11.2.0.1.0 - Production on Tue Nov 18 17:44:25 2014
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 "SYSTEM"."SYS_EXPORT_TRANSPORTABLE_01": system/******** directory=tbs_dir dumpfile=p1.dmp transport_tablespaces=tbs1,tbs1_indx logfile=p1.log
ORA-39123: Data Pump transportable tablespace job aborted
ORA-39187: The transportable set is not self-contained, violation list is
ORA-39901: Partitioned table SCOTT.T1 is partially contained in the transportable set.
ORA-39921: Default Partition (Table) Tablespace USERS for T1 not contained in transportable set.
Job "SYSTEM"."SYS_EXPORT_TRANSPORTABLE_01" stopped due to fatal error at 17:44:49
传输表空间出错,表空间处于非自包含模式:
18:14:47 SYS@ prod >exec dbms_tts.transport_set_check('TBS1',true);
PL/SQL procedure successfully completed.
18:17:49 SYS@ prod >select * from transport_set_violations;
VIOLATIONS
------------------------------------------------------------------------------------------------------------------------
ORA-39921: Default Partition (Table) Tablespace USERS for T1 not contained in transportable set.
.
ORA-39901: Partitioned table SCOTT.T1 is partially contained in the transportable set.
解决方法,需要创建一个临时表和一个临时表索引,将分区和分区索引交换到临时表和临时表索引表空间上,然后到处临时表和临时表索引。由于临时表不是分区表,它们呢所在的表空间符合自包含条件。
17:45:37 SCOTT@ prod >create table t1_tmp as select * from t1 where 1=3;
Table created.
Elapsed: 00:00:00.20
17:45:58 SCOTT@ prod >create index t1_tmp_indx on t1_tmp(id);
Index created.
17:46:33 SCOTT@ prod >select segment_name,tablespace_name from user_segments
17:47:18 2 where segment_name in ('T1_TMP','T1_TMP_INDX');
SEGMENT_NAME TABLESPACE_NAME
--------------------------------------------------------------------------------- ------------------------------
T1_TMP USERS
T1_TMP_INDX USERS
将分区表交换到临时表:
17:48:32 SCOTT@ prod >alter table t1 exchange partition p1 with table t1_tmp including indexes;
T |