当表刚创建的时候它的object_id和data_object_id都是相等的,但是如果表经过move或truncate等,涉及到segment发生改变后data_object_id将会有变化。
DATA_OBJECT_ID was introduced in 8.0 to track versions of the same segment (certain operations change the version). It is used to discover stale ROWIDs and stale undo records.
下面我们就通过示例来逐步了解一下:
1、新建表
SQL> create table sdxj.xiaoxu_objectid as select * from dba_objects;
表已创建。
2、查看object_id和data_object_id
SQL> select owner,object_name,object_id,data_object_id from dba_objects where object_name='XIAOXU_OBJECTID';
OWNER OBJECT_NAME OBJECT_ID DATA_OBJECT_ID
---------- -------------------------------------------------- ---------- --------------
SDXJ XIAOXU_OBJECTID 77782 77782
----初始大小相等。
3、通过move,create ,alter,truncate 操作观察id变化
3.1 move 操作
SQL> alter table sdxj.xiaoxu_objectid move;
表已更改。
SQL> select owner,object_name,object_id,data_object_id from dba_objects where object_name='XIAOXU_OBJECTID';
OWNER OBJECT_NAME OBJECT_ID DATA_OBJECT_ID
---------- -------------------------------------------------- ---------- --------------
SDXJ XIAOXU_OBJECTID 77782 77783 ---此时object_id不变,data_object_id 发生变化,值增加。
3.2 create index 操作
SQL > create index sdxj.idx_objectid on sdxj.xiaoxu_objectid (object_id) tablespace d_data_01;
SQL> select owner,object_name,object_id,data_object_id from dba_objects where object_name='XIAOXU_OBJECTID';
OWNER OBJECT_NAME OBJECT_ID DATA_OBJECT_ID
---------- -------------------------------------------------- ---------- --------------
SDXJ XIAOXU_OBJECTID 77782 77783 ---创建索引两个值未变。
3.3 alter index 操作
SQL> alter index sdxj.idx_objectid rebuild tablespace users;
索引已更改。
SQL> select owner,object_name,object_id,data_object_id from dba_objects where object_name='XIAOXU_OBJECTID';
OWNER OBJECT_NAME OBJECT_ID DATA_OBJECT_ID
---------- -------------------------------------------------- ---------- --------------
SDXJ XIAOXU_OBJECTID 77782 77783 --经测试alter index ,create indexes,insert into 均未发生变化。
3.4、truncate 操作
SQL> truncate table sdxj.XIAOXU_OBJECTID;
表被截断。
SQL> select owner,object_name,object_id,data_object_id from dba_objects where object_name='XIAOXU_OBJECTID';
OWNER OBJECT_NAME OBJECT_ID DATA_OBJECT_ID
---------- -------------------------------------------------- ---------- --------------
SDXJ XIAOXU_OBJECTID 77782 77790 --值发生变化。
据听说,data_object_id 到大2^32次方,会导致数据库HAND住。