ITPub博客

首页 > 数据库 > Oracle > OBJECT_ID和DATA_OBJECT_ID关系

OBJECT_ID和DATA_OBJECT_ID关系

原创 Oracle 作者:goasktom 时间:2014-05-20 18:27:00 0 删除 编辑
参考:https://asktom.oracle.com/pls/apex/f?p=100:11:0::::P11_QUESTION_ID:23417970272903

1.OBJECT_ID和DATA_OBJECT_ID的关系 

A>create table d as select * from a;

Table created.

-- 刚开始表D的OBJECT_ID和DATA_OBJECT_ID是一样的

A>select OBJECT_ID,DATA_OBJECT_ID from dba_objects where OBJECT_NAME='D';

 OBJECT_ID DATA_OBJECT_ID
---------- --------------
     59523          59523

--truncate以后,DATA_OBJECT_ID发生了变化

A>truncate table d;

Table truncated.

A>select OBJECT_ID,DATA_OBJECT_ID from dba_objects where OBJECT_NAME='D';

 OBJECT_ID DATA_OBJECT_ID
---------- --------------
     59523          59524

--move以后同样发生了变化

A>alter table d move;

Table altered.

A>select OBJECT_ID,DATA_OBJECT_ID from dba_objects where OBJECT_NAME='D';

 OBJECT_ID DATA_OBJECT_ID
---------- --------------
     59523          59525

--每move一次,DATA_OBJECT_ID就变一次

A>alter table d move;

Table altered.

A>select OBJECT_ID,DATA_OBJECT_ID from dba_objects where OBJECT_NAME='D';

 OBJECT_ID DATA_OBJECT_ID
---------- --------------
     59523          59526

--但truncate只在第一次操作时,才会导致DATA_OBJECT_ID发生变化,此后再truncate也不会再变了

A>truncate table d;

Table truncated.

A>select OBJECT_ID,DATA_OBJECT_ID from dba_objects where OBJECT_NAME='D';

 OBJECT_ID DATA_OBJECT_ID
---------- --------------
     59523          59526

2.DATA_OBJECT_ID和ROWID的关系

3.关于这三者之间的关系,asktom上有两段话说的很好

there is an object id, the primary key into obj$ to find the metadata about the table.
there is the data_object_id which starts life as the same as the object id but changes every time you truncate... it points to the actual data segment


Object id is defined as object creation time, the object then has a data object id equals to the
object id.
This data object id is something like an object instantiation id. When you truncate a table, it
keeps its object id but data object id changes.
The reason is clear: it prevents from using old ROWID from a previous "table instantiation".
ROWID contains data object id, when you try to use a rowid then this data object id is compared to
the one recorded in block header. If they don't match then you're trying to use an old and no more
valid rowid and an error is returned.

参考:https://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:486662100346064066

附一 ROWID格式

OOOOOO.FFF.BBBBBB.SSS

where:
   OOOOOO is the data object number.
   FFF is the relative file number.
   BBBBBB is the block number.
   SSS is the slot number.

 

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/29646619/viewspace-1165510/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2014-05-07

  • 博文量
    27
  • 访问量
    43325