[20130708]傳輸表空間與data_object_id.txt
[20130708]傳輸表空間與data_object_id.txt
傳輸表空間與scn.txt:http://space.itpub.net/267265/viewspace-750140
初學者經常搞混檢視dba_objects中object_id和data_object_id,一般建立表兩者是相等的,容易混淆。建立分割槽表的話,表僅僅有
object_id,沒有data_object_id,分割槽表才有data_object_id。
實際上有些物件比如view,sequence等僅僅有object_id,而沒有段的分配即沒有data_object_id。db_link兩者都沒有。像表在truncate
(有資料的情況下),move的情況下data_object_id會發生變化。
--如果使用傳輸表空間,匯入的是metadate資料,資料檔案裡面的data_object_id一定沒有改變,這樣有可能會出現
--data_object_id重複的情況。自己做一個測試看看。
1.測試環境:
CREATE TABLESPACE AAA DATAFILE
'/u01/app/oracle11g/oradata/test/aaa01.dbf' SIZE 65528K AUTOEXTEND ON NEXT 16M MAXSIZE UNLIMITED
LOGGING
ONLINE
PERMANENT
EXTENT MANAGEMENT LOCAL AUTOALLOCATE
BLOCKSIZE 8K
SEGMENT SPACE MANAGEMENT AUTO
FLASHBACK ON;
SQL> create table t tablespace aaa as select rownum id,'test' name from dual connect by level<=10;
Table created.
2.測試是否可以傳輸表空間(sys使用者執行):
SQL> exec dbms_tts.transport_set_check('AAA',TRUE);
PL/SQL procedure successfully completed.
SQL> select * from transport_set_violations ;
no rows selected
SQL> alter tablespace aaa read only;
Tablespace altered.
$ exp \"/ as sysdba\" tablespaces=aaa transport_tablespace=y file=aaa.dmp
Export: Release 11.2.0.3.0 - Production on Mon Jul 8 09:44:10 2013
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Export done in ZHS16GBK character set and AL16UTF16 NCHAR character set
Note: table data (rows) will not be exported
About to export transportable tablespace metadata...
For tablespace AAA ...
. exporting cluster definitions
. exporting table definitions
. . exporting table T
. exporting referential integrity constraints
. exporting triggers
. end transportable tablespace metadata export
Export terminated successfully without warnings.
--做一個備用。
$ cp /u01/app/oracle11g/oradata/test/aaa01.dbf /tmp/aaa01.dbf
3.匯入傳輸表空間,由於僅僅1個測試資料庫。我修改表空間名字以及裡面的表。執行如下:
SQL> alter tablespace aaa read write ;
Tablespace altered.
SQL> alter tablespace aaa rename to bbb;
Tablespace altered.
SQL> alter table scott.t rename to torg;
Table altered.
--可以發現rename表名t,OBJECT_ID,DATA_OBJECT_ID並沒有發生變化,依舊是276982。
--修改資料檔名字
SQL> alter tablespace BBB offline normal;
$ mv /u01/app/oracle11g/oradata/test/aaa01.dbf /u01/app/oracle11g/oradata/test/bbb01.dbf
SQL> alter database rename file '/u01/app/oracle11g/oradata/test/aaa01.dbf' to '/u01/app/oracle11g/oradata/test/bbb01.dbf'
SQL> alter tablespace BBB online
--這樣在匯入不會出現衝突情況。
$ cp /tmp/aaa01.dbf /u01/app/oracle11g/oradata/test/aaa01.dbf
$ imp \'\/ as sysdba\' tablespaces=aaa transport_tablespace=y file=aaa.dmp datafiles=/u01/app/oracle11g/oradata/test/aaa01.dbf
Import: Release 11.2.0.3.0 - Production on Mon Jul 8 10:04:34 2013
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Export file created by EXPORT:V11.02.00 via conventional path
About to import transportable tablespace(s) metadata...
import done in ZHS16GBK character set and AL16UTF16 NCHAR character set
. importing SYS's objects into SYS
. importing SYS's objects into SYS
. importing SCOTT's objects into SCOTT
. . importing table "T"
. importing SYS's objects into SYS
Import terminated successfully without warnings.
--可以發現一個情況,表T與TORG的DATA_OBJECT_ID都是276982。OBJECT_ID不同。
--從另外的側面可以說明在一個資料庫,DATA_OBJECT_ID相同,而物件可以不同。
--希望這篇文章對許多beginner更好的理解OBJECT_ID,DATA_OBJECT_ID.
傳輸表空間與scn.txt:http://space.itpub.net/267265/viewspace-750140
初學者經常搞混檢視dba_objects中object_id和data_object_id,一般建立表兩者是相等的,容易混淆。建立分割槽表的話,表僅僅有
object_id,沒有data_object_id,分割槽表才有data_object_id。
實際上有些物件比如view,sequence等僅僅有object_id,而沒有段的分配即沒有data_object_id。db_link兩者都沒有。像表在truncate
(有資料的情況下),move的情況下data_object_id會發生變化。
SQL> select object_id,data_object_id from dba_objects where wner=user and object_name='V_DEPT';
OBJECT_ID DATA_OBJECT_ID
---------- --------------
269361
SQL> select object_id,data_object_id from dba_objects where object_name='SEQ1';
OBJECT_ID DATA_OBJECT_ID
---------- --------------
275186
SQL> select object_name,object_id,data_object_id from dba_objects where object_name='TEST1.COM';
OBJECT_NAME OBJECT_ID DATA_OBJECT_ID
-------------------- ---------- --------------
TEST1.COM
--如果使用傳輸表空間,匯入的是metadate資料,資料檔案裡面的data_object_id一定沒有改變,這樣有可能會出現
--data_object_id重複的情況。自己做一個測試看看。
1.測試環境:
SQL> @ver
BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
CREATE TABLESPACE AAA DATAFILE
'/u01/app/oracle11g/oradata/test/aaa01.dbf' SIZE 65528K AUTOEXTEND ON NEXT 16M MAXSIZE UNLIMITED
LOGGING
ONLINE
PERMANENT
EXTENT MANAGEMENT LOCAL AUTOALLOCATE
BLOCKSIZE 8K
SEGMENT SPACE MANAGEMENT AUTO
FLASHBACK ON;
SQL> create table t tablespace aaa as select rownum id,'test' name from dual connect by level<=10;
Table created.
SQL> select object_name,object_id,data_object_id from dba_objects where wner=user and object_name='T';
OBJECT_NAME OBJECT_ID DATA_OBJECT_ID
-------------------- ---------- --------------
T 276982 276982
2.測試是否可以傳輸表空間(sys使用者執行):
SQL> exec dbms_tts.transport_set_check('AAA',TRUE);
PL/SQL procedure successfully completed.
SQL> select * from transport_set_violations ;
no rows selected
SQL> alter tablespace aaa read only;
Tablespace altered.
$ exp \"/ as sysdba\" tablespaces=aaa transport_tablespace=y file=aaa.dmp
Export: Release 11.2.0.3.0 - Production on Mon Jul 8 09:44:10 2013
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Export done in ZHS16GBK character set and AL16UTF16 NCHAR character set
Note: table data (rows) will not be exported
About to export transportable tablespace metadata...
For tablespace AAA ...
. exporting cluster definitions
. exporting table definitions
. . exporting table T
. exporting referential integrity constraints
. exporting triggers
. end transportable tablespace metadata export
Export terminated successfully without warnings.
--做一個備用。
$ cp /u01/app/oracle11g/oradata/test/aaa01.dbf /tmp/aaa01.dbf
3.匯入傳輸表空間,由於僅僅1個測試資料庫。我修改表空間名字以及裡面的表。執行如下:
SQL> alter tablespace aaa read write ;
Tablespace altered.
SQL> alter tablespace aaa rename to bbb;
Tablespace altered.
SQL> alter table scott.t rename to torg;
Table altered.
SQL> select object_name,object_id,data_object_id from dba_objects where wner='SCOTT' and object_name='TORG';
OBJECT_NAME OBJECT_ID DATA_OBJECT_ID
-------------------- ---------- --------------
TORG 276982 276982
--可以發現rename表名t,OBJECT_ID,DATA_OBJECT_ID並沒有發生變化,依舊是276982。
--修改資料檔名字
SQL> alter tablespace BBB offline normal;
$ mv /u01/app/oracle11g/oradata/test/aaa01.dbf /u01/app/oracle11g/oradata/test/bbb01.dbf
SQL> alter database rename file '/u01/app/oracle11g/oradata/test/aaa01.dbf' to '/u01/app/oracle11g/oradata/test/bbb01.dbf'
SQL> alter tablespace BBB online
--這樣在匯入不會出現衝突情況。
$ cp /tmp/aaa01.dbf /u01/app/oracle11g/oradata/test/aaa01.dbf
$ imp \'\/ as sysdba\' tablespaces=aaa transport_tablespace=y file=aaa.dmp datafiles=/u01/app/oracle11g/oradata/test/aaa01.dbf
Import: Release 11.2.0.3.0 - Production on Mon Jul 8 10:04:34 2013
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Export file created by EXPORT:V11.02.00 via conventional path
About to import transportable tablespace(s) metadata...
import done in ZHS16GBK character set and AL16UTF16 NCHAR character set
. importing SYS's objects into SYS
. importing SYS's objects into SYS
. importing SCOTT's objects into SCOTT
. . importing table "T"
. importing SYS's objects into SYS
Import terminated successfully without warnings.
SQL> select object_name,object_id,data_object_id from dba_objects where wner='SCOTT' and object_name in ('TORG','T');
OBJECT_NAME OBJECT_ID DATA_OBJECT_ID
-------------------- ---------- --------------
T 276986 276982
TORG 276982 276982
--可以發現一個情況,表T與TORG的DATA_OBJECT_ID都是276982。OBJECT_ID不同。
--從另外的側面可以說明在一個資料庫,DATA_OBJECT_ID相同,而物件可以不同。
--希望這篇文章對許多beginner更好的理解OBJECT_ID,DATA_OBJECT_ID.
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-765713/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- MySQL 傳輸表空間MySql
- Oracle 表空間傳輸Oracle
- oracle表空間傳輸Oracle
- Oracle傳輸表空間Oracle
- MySQL表空間傳輸MySql
- mysql之 表空間傳輸MySql
- 傳輸表空間操作-OracleOracle
- Oracle傳輸表空間(TTS)OracleTTS
- Oracle 傳輸表空間-RmanOracle
- 總結-表空間傳輸
- 跨平臺表空間遷移(傳輸表空間)
- 【傳輸表空間】使用 EXPDP/IMPDP工具的傳輸表空間完成資料遷移
- 基於可傳輸表空間的表空間遷移
- Oracle傳輸表空間學習Oracle
- Oracle 傳輸表空間-EXPDP/IMPDPOracle
- Oracle 傳輸表空間-EXP/IMPOracle
- 傳輸表空間自包含理解
- Oracle表空間傳輸詳解Oracle
- 【傳輸表空間】使用 EXPDP/IMPDP工具的傳輸表空間完成資料遷移[轉]
- oracle 傳輸表空間一例Oracle
- Oracle可傳輸表空間測試Oracle
- 5.7 mysql的可傳輸表空間MySql
- 表空間傳輸讀書筆記筆記
- oracle跨版本與平臺執行傳輸表空間Oracle
- 【XTTS】Oracle傳輸表空間xtts增量方式TTSOracle
- 傳輸表空間(從Linux到Windows)LinuxWindows
- oracle可傳輸表空間TTS小結OracleTTS
- 傳輸表空間及問題處理
- oracle表空間傳輸的限制條件Oracle
- 實戰RMAN備份傳輸表空間
- 使用Oracle可傳輸表空間的特性複製資料(7)實戰RMAN備份傳輸表空間Oracle
- 12c 資料泵傳輸表空間
- 資料泵 TTS(傳輸表空間技術)TTS
- 聊聊Oracle可傳輸表空間(Transportable Tablespace)(上)Oracle
- 聊聊Oracle可傳輸表空間(Transportable Tablespace)(中)Oracle
- 聊聊Oracle可傳輸表空間(Transportable Tablespace)(下)Oracle
- MySQL Transportable Tablespace(傳輸表空間) 使用詳解MySql
- 12c跨平臺傳輸表空間