傳輸表空間實驗

windows xp操作系統,從數據庫study把表空間test傳輸到數據庫test。
study用戶連接到study庫,在test表空間建表test_test
SQL> create table test_test(id number,name varchar2(10)) tablespace test
  2  /
Table created
 
SQL> insert into test_test values(1,'guojje')
  2  /
 
1 row inserted
 
SQL> commit
  2  /
把索引建到表空間user上
SQL> create index idx_test_test on test_test(id) tablespace users
  2  /
Index created
在USERS表空間上建users_test表
SQL> create table users_test(id number,name varchar2(10)) tablespace users
  2  /
 
Table created
 
SQL> insert into users_test values(1,'guojje_u')
  2  /
 
1 row inserted
 
SQL> commit
  2  /
把索引建到表空間test上
SQL> create index idx_users_test on users_test(id) tablespace test
  2  /
Index created
執行自包含檢查,分兩種,一般自包含與嚴格自包含。
執行一般自含檢查:
SQL> exec sys.dbms_tts.TRANSPORT_SET_CHECK('test',true)
PL/SQL procedure successfully completed
 
SQL>  select * from sys.transport_set_violations
  2  /
 
VIOLATIONS
--------------------------------------------------------------------------------
Index STUDY.IDX_USERS_TEST in tablespace TEST points to table STUDY.USERS_TEST in tablespace USERS
顯示說含有別人的索引。
執行嚴格檢查:
SQL> exec sys.dbms_tts.TRANSPORT_SET_CHECK('test',true,true)
PL/SQL procedure successfully completed
SQL>  select * from sys.transport_set_violations
  2  /
VIOLATIONS
-----------------------------------------------------------------------------------------------------
Index STUDY.IDX_TEST_TEST in tablespace USERS points to table STUDY.TEST_TEST in tablespace TEST
Index STUDY.IDX_USERS_TEST in tablespace TEST points to table STUDY.USERS_TEST in tablespace USERS
顯示說含有別人的索引,自已的索引在別人那兒。
只要滿足一般自包含就可以,只是索引沒有被傳輸到目的數據庫。即自已的可以丟掉,但不能把別人的拿走.
C:\Documents and Settings\Administrator>expdp study/study@mystudy dumpfile=test.
dmp directory=test transport_tablespaces=test
Export: Release 10.2.0.1.0 - Production on 星期六, 19 6月, 2010 22:19:29
Copyright (c) 2003, 2005, Oracle.  All rights reserved.
連接到: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
啓動 "STUDY"."SYS_EXPORT_TRANSPORTABLE_01":  study/********@mystudy dumpfile=tes
t.dmp directory=test transport_tablespaces=test
ORA-39123: 數據泵可傳輸的表空間作業中止
ORA-29335: 表空間 'TEST' 不爲只讀
作業 "STUDY"."SYS_EXPORT_TRANSPORTABLE_01" 因致命錯誤於 22:19:32 停止
表空間必須只讀狀態:
SQL> alter tablespace test read only
  2  /
Tablespace altered
C:\Documents and Settings\Administrator>expdp study/study@mystudy dumpfile=test.
dmp directory=test transport_tablespaces=test
Export: Release 10.2.0.1.0 - Production on 星期六, 19 6月, 2010 22:20:59
Copyright (c) 2003, 2005, Oracle.  All rights reserved.
連接到: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
啓動 "STUDY"."SYS_EXPORT_TRANSPORTABLE_01":  study/********@mystudy dumpfile=tes
t.dmp directory=test transport_tablespaces=test
處理對象類型 TRANSPORTABLE_EXPORT/PLUGTS_BLK
處理對象類型 TRANSPORTABLE_EXPORT/TABLE
處理對象類型 TRANSPORTABLE_EXPORT/POST_INSTANCE/PLUGTS_BLK
已成功加載/卸載了主表 "STUDY"."SYS_EXPORT_TRANSPORTABLE_01"
******************************************************************************
STUDY.SYS_EXPORT_TRANSPORTABLE_01 的轉儲文件集爲:
  D:\TEST\TEST.DMP
作業 "STUDY"."SYS_EXPORT_TRANSPORTABLE_01" 已於 22:21:12 成功完成
手工把數據文件拷過去,文件名可以更改。
C:\Documents and Settings\Administrator>impdp 'sys/system@test as sysdba' dumpfi
le=test.dmp directory=test transport_datafiles='D:\oracle\product\10.2.0\oradata
\TEST\DATAFILE\O1_MF_TEST_61SJGJ98_1.DBF'
Import: Release 10.2.0.1.0 - Production on 星期六, 19 6月, 2010 22:35:10
Copyright (c) 2003, 2005, Oracle.  All rights reserved.
連接到: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
已成功加載/卸載了主表 "SYS"."SYS_IMPORT_TRANSPORTABLE_01"
啓動 "SYS"."SYS_IMPORT_TRANSPORTABLE_01":  'sys/********@test AS SYSDBA' dumpfil
e=test.dmp directory=test transport_datafiles='D:\oracle\product\10.2.0\oradata\
TEST\DATAFILE\O1_MF_TEST_61SJGJ98_1.DBF'
處理對象類型 TRANSPORTABLE_EXPORT/PLUGTS_BLK
處理對象類型 TRANSPORTABLE_EXPORT/TABLE
處理對象類型 TRANSPORTABLE_EXPORT/POST_INSTANCE/PLUGTS_BLK
作業 "SYS"."SYS_IMPORT_TRANSPORTABLE_01" 已於 22:35:13 成功完成
在數據庫test上執行:
SQL> select * from study.test_test
  2  /
 
        ID NAME
---------- ----------
         1 guojje
成功完成傳輸。
最後記得把兩個庫的test表空間都置入read write
SQL>alter tablespace test read, write.
備:
我的EM上執行空間傳輸時總報錯,發現是在Convert datafile時出錯,手工執行轉換:
RMAN> convert tablespace TEST to platform 'Microsoft Windows IA (32-bit)'  format='D:\test\test.dbf' 報rman-20202:在恢復目錄中未找到表空間。換其他表空間均正常。後來把表空間名改成TEST2,運行成功,可能RMAN把TEST當關鍵字了。


 
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章