oracle實驗記錄 (exp/imp transport tablespace)

fufuh2o發表於2009-09-29

使用exp imp
transport tablespace
與使用expdp/impdp是步驟一樣的  語法上有些不一樣


限制條件與expdp/impdp一樣 (檢視expdp/impdp transport tablespace)

將db xh tablespace smallts transport 到db orcl
SQL> conn tr/a123@xh 
已連線。
SQL> select tablespace_name from dba_tablespaces;

TABLESPACE_NAME
------------------------------
SYSTEM
UNDOTBS1
SYSAUX
TEMP
USERS
EXAMPLE
RMAN_TS
XHTEST
XHTR
OUTLINE_TS
SMALLTS

已選擇11行。

SQL> select count(*) from t1;

  COUNT(*)
----------
         0

SQL> insert into t1 values(1);

已建立 1 行。

SQL> select count(*) from t1;

  COUNT(*)
----------
         1

SQL> commit;

提交完成。

SQL> select tablespace_name from user_tables where table_name='T1';

TABLESPACE_NAME
------------------------------
USERS

SQL> alter table t1 move tablespace smallts;

表已更改。

SQL> select tablespace_name from user_tables where table_name='T1';

TABLESPACE_NAME
------------------------------
SMALLTS


SQL> execute sys.dbms_tts.transport_set_check('smallts',true,true);

PL/SQL 過程已成功完成。

 

SQL> select * from sys.transport_set_violations;

VIOLATIONS
--------------------------------------------------------------------------------
Index TR.T1_IND in tablespace USERS points to table TR.T1 in tablespace SMALLTS


發現t1_ind 在USER TABLESPACE 與表不在同一個表空間
(expdp的話用TRANSPORT_FULL_CHECK 設定為N 可以匯出時候不報告錯誤 成功匯出 不過只匯出INDEX 所在表空間 不匯出依賴的表所在表空間還是會報錯,impdp時也一樣)(exp/imp時用 TTS_FULL_CHECK 一樣) 在這裡 我們還是手動解決下這個問題

SQL> alter index t1_IND REBUilD TABLESPACE smallts
  2  ;

索引已更改。

SQL> execute sys.dbms_tts.transport_set_check('smallts',true,true);

PL/SQL 過程已成功完成。

SQL> select * from sys.transport_set_violations;

未選定行~~~~~~~~~~~~~~~~~可以了


C:\>set oracle_sid=orcl
C:\>sqlplus / as sysdba

SQL*Plus: Release 10.2.0.1.0 - Production on 星期二 9月 29 11:43:05 2009

Copyright (c) 1982, 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

SQL> select name from v$database;

NAME
---------
ORCL
SQL> select tablespace_name from dba_tablespaces;

TABLESPACE_NAME
------------------------------
SYSTEM
UNDOTBS1
SYSAUX
TEMP
USERS
EXAMPLE
TEST
RMAN_TS
TESTXH
XHTEST
XHTR

已選擇11行。

 

 

SQL> host exp 'sys/a831115@xh as sysdba' transport_tablespace=y file=d:\exp\tablesp
ace.dmp tablespaces=smallts

Export: Release 10.2.0.1.0 - Production on 星期二 9月 29 11:47:43 2009

Copyright (c) 1982, 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
已匯出 ZHS16GBK 字符集和 AL16UTF16 NCHAR 字符集
注: 將不匯出表資料 (行)
即將匯出可傳輸的表空間後設資料...
EXP-00008: 遇到 ORACLE 錯誤 29335
ORA-29335: 表空間 'SMALLTS' 不為只讀~~~~~~~~必須要 read only
ORA-06512: 在 "SYS.DBMS_PLUGTS", line 507
ORA-06512: 在 line 1
EXP-00000: 匯出終止失敗


另外必須  sysdba connect(EXP-00044: 必須以 'SYSDBA' 身份連線, 才能進行時間點恢復或可傳輸的表空間匯入)
SQL> alter tablespace smallts read only;

表空間已更改。

SQL> host exp 'sys/a831115@xh as sysdba' transport_tablespace=y file=d:\exp\tablesp
ace.dmp tablespaces=smallts

Export: Release 10.2.0.1.0 - Production on 星期二 9月 29 11:48:10 2009

Copyright (c) 1982, 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
已匯出 ZHS16GBK 字符集和 AL16UTF16 NCHAR 字符集
注: 將不匯出表資料 (行)
即將匯出可傳輸的表空間後設資料...
對於表空間 SMALLTS...
. 正在匯出簇定義
. 正在匯出表定義
. . 正在匯出表                              T1
. 正在匯出引用完整性約束條件
. 正在匯出觸發器
. 結束匯出可傳輸的表空間後設資料
成功終止匯出, 沒有出現警告。

SQL> host copy d:\xhdatafile\smallfile.dbf E:\orcldatafile\smallfile.dbf
已複製         1 個檔案。

 

SQL> alter tablespace smallts read write
  2  ;

表空間已更改。

 

orcl db
SQL> host imp '/ as sysdba'  transport_tablespace=y file=d:\exp\tablespace.dmp data
files=e:\orcldatafile\smallfile.dbf fromuser=tr touser=system

Import: Release 10.2.0.1.0 - Production on 星期二 9月 29 11:54:31 2009

Copyright (c) 1982, 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

經由常規路徑由 EXPORT:V10.02.01 建立的匯出檔案
即將匯入可傳輸的表空間後設資料...
已經完成 ZHS16GBK 字符集和 AL16UTF16 NCHAR 字符集中的匯入
. 正在將 TR 的物件匯入到 SYSTEM
. . 正在匯入表                            "T1"
成功終止匯入, 沒有出現警告。

SQL> conn system/a831115
已連線。
SQL> select count(*) from t1;

  COUNT(*)
----------
         1

SQL> select tablespace_name from user_tables where table_name='T1';

TABLESPACE_NAME
------------------------------
SMALLTS

SQL> select file_name from dba_data_files where tablespace_name='SMALLTS';

FILE_NAME
--------------------------------------------------------------------------------
E:\ORCLDATAFILE\SMALLFILE.DBF

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/12020513/viewspace-615847/,如需轉載,請註明出處,否則將追究法律責任。

相關文章