oracle object_id与data_object_id的关系与区别

教程发布:风哥 教程分类:ITPUX技术网 更新日期:2022-02-12 浏览学习:1159

oracle object_id与data_object_id的关系

object_id 是逻辑对象ID
data_object_id 是物理对象ID
SQL> create table test as select rownum rn from dba_objects;
Table created.
SQL> select object_id,data_object_id from dba_objects where object_name='TEST' A
ND WNER='SYS';
OBJECT_ID DATA_OBJECT_ID
---------- --------------
6680 6680
SQL> select header_file,header_block,blocks from dba_segments where segment_name
='TEST' and WNER='SYS';
HEADER_FILE HEADER_BLOCK BLOCKS
----------- ------------ ----------
1 42921 16
SQL> alter table test move;
Table altered.
SQL> select object_id,data_object_id from dba_objects where object_name='TEST' A
ND WNER='SYS';
OBJECT_ID DATA_OBJECT_ID
---------- --------------
6680 6681
表经过move后,物理ID发生变化
SQL> select header_file,header_block,blocks from dba_segments where segment_name
='TEST' and WNER='SYS';
HEADER_FILE HEADER_BLOCK BLOCKS
----------- ------------ ----------
1 43105 16
SQL> truncate table test;
Table truncated.
SQL> select header_file,header_block,blocks from dba_segments where segment_name
='TEST' and WNER='SYS';
HEADER_FILE HEADER_BLOCK BLOCKS
----------- ------------ ----------
1 43105 8
SQL> select object_id,data_object_id from dba_objects where object_name='TEST' A
ND WNER='SYS';
OBJECT_ID DATA_OBJECT_ID
---------- --------------
6680 6682
表经过truncate 后 物理ID也发生变化

SQL> alter table test add(n number);
Table altered.
SQL> select object_id,data_object_id from dba_objects where object_name='TEST' A
ND WNER='SYS';
OBJECT_ID DATA_OBJECT_ID
---------- --------------
6680 6682
给表增加一个列,也没发生变化
所以总上所简述
只有当segment发生变化时data_object_id才发生变化
有时候我们根据rowid 算时得到的data_object_id会误以为就是object_id,因为要是没有发生segment变化时
两者值是相等的

本文标签:
网站声明:本文由风哥整理发布,转载请保留此段声明,本站所有内容将不对其使用后果做任何承诺,请读者谨慎使用!
【上一篇】
【下一篇】