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后data_object_id会发生变化。修改表结构不会更改。
SQL> create table ldy.obid as select rownum as "rn" from dba_objects;
表已创建。
SQL> select object_id,data_object_id from dba_objects where object_name='OBID' and owner='LDY';
OBJECT_ID DATA_OBJECT_ID
---------- --------------
12436 12436
SQL> select header_file,header_block,blocks from dba_segments where segment_name='OBID' and owner='LDY';
HEADER_FILE HEADER_BLOCK BLOCKS
----------- ------------ ----------
7 190347 24
SQL> alter table ldy.obid move;
表已更改。
SQL> select object_id,data_object_id from dba_objects where object_name='OBID' and owner='LDY';
OBJECT_ID DATA_OBJECT_ID
---------- --------------
12436 12437
表经过move后,物理ID发生变化.
SQL> select header_file,header_block,blocks from dba_segments where segment_name='OBID' and owner='LDY';
HEADER_FILE HEADER_BLOCK BLOCKS
----------- ------------ ----------
7 190371 24
SQL> truncate table ldy.obid;
表被截断。
SQL> select object_id,data_object_id from dba_objects where object_name='OBID' and owner='LDY';
OBJECT_ID DATA_OBJECT_ID
---------- --------------
12436 12438
SQL> select header_file,header_block,blocks from dba_segments where segment_name='OBID' and owner='LDY';
HEADER_FILE HEADER_BLOCK BLOCKS
----------- ------------ ----------
7 190371 8
表经过truncate 后 物理ID也发生变化。
SQL> alter table ldy.obid add (n number);
表已更改。
SQL> select object_id,data_object_id from dba_objects where object_name='OBID' and owner='LDY';
OBJECT_ID DATA_OBJECT_ID
---------- --------------
12436 12438
SQL> select header_file,header_block,blocks from dba_segments where segment_name='OBID' and owner='LDY';
HEADER_FILE HEADER_BLOCK BLOCKS
----------- ------------ ----------
7 190371 8
给表增加一个列,也没发生变化
所以总上所简述
只有当segment发生变化时data_object_id才发生变化
有时候我们根据rowid 算时得到的data_object_id会误以为就是object_id,因为要是没有发生segment变化时
两者值是相等的
阅读(868) | 评论(0) | 转发(0) |