object_id和data_object_id区别与联系

联系:手机/微信(+86 17813235971) QQ(107644445)

标题:object_id和data_object_id区别与联系

作者:惜分飞©版权所有[未经本人同意,不得以任何形式转载,否则有进一步追究法律责任的权利.]

其实object_id和data_object_id同样是表示数据库对象的一个唯一标志,但是object_id表示的是逻辑id,data_object_id表示的是物理id。如果一些object没有物理属性的话那它就不存在data_object_id,例如procedure,function,package,data type,db link,mv定义,view定义,临时表,分区表定义等等这些object都是没有对应着某个segment,因此它们的data_object_id都为空。

当表刚创建的时候它的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.

SQL> create table xff as select * from dba_objects where rownum<100;
Table created
SQL> select object_id,data_object_id from user_objects where object_name='XFF';
 OBJECT_ID DATA_OBJECT_ID
---------- --------------
    211325         211325
SQL> alter table xff move;
Table altered
SQL> select object_id,data_object_id from user_objects where object_name='XFF';
 OBJECT_ID DATA_OBJECT_ID
---------- --------------
    211325         211326
SQL> truncate table xff;
Table truncated
SQL> create index ind_xff on xff(object_id);
Index created
SQL>  select object_id,data_object_id from user_objects where object_name='IND_XFF';
 OBJECT_ID DATA_OBJECT_ID
---------- --------------
    211328         211328
SQL> ALTER INDEX IND_XFF REBUILD;
Index altered
SQL>  select object_id,data_object_id from user_objects where object_name='IND_XFF';
 OBJECT_ID DATA_OBJECT_ID
---------- --------------
    211328         211329

发表评论

邮箱地址不会被公开。 必填项已用*标注

10 − 3 =