其实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 10G>select object_id,data_object_id from user_objects where object_name='T';
SQL 10G>select object_id,data_object_id from user_objects where object_name='T';
OBJECT_ID DATA_OBJECT_ID
---------- --------------
63053 63053
---------- --------------
63053 63053
刚开始创建表时object_id=data_object_id。
SQL 10G>SELECT HEADER_FILE,HEADER_BLOCK,BLOCKS FROM DBA_SEGMENTS WHERE SEGMENT_NAME='T' AND OWNER='TEST';
HEADER_FILE HEADER_BLOCK BLOCKS
----------- ------------ ----------
4 2019 8
----------- ------------ ----------
4 2019 8
SQL 10G>alter table t move;
Table altered.
SQL 10G>select object_id,data_object_id from user_objects where object_name='T';
OBJECT_ID DATA_OBJECT_ID
---------- --------------
63053 63463
---------- --------------
63053 63463
在move以后可以看到data_object_id发生变化了。
SQL 10G>SELECT HEADER_FILE,HEADER_BLOCK,BLOCKS FROM DBA_SEGMENTS WHERE SEGMENT_NAME='T' AND OWNER='TEST';
HEADER_FILE HEADER_BLOCK BLOCKS
----------- ------------ ----------
4 467 8
----------- ------------ ----------
4 467 8
SQL 10G>truncate table t;
Table truncated.
SQL 10G>select object_id,data_object_id from user_objects where object_name='T';
OBJECT_ID DATA_OBJECT_ID
---------- --------------
63053 63464
---------- --------------
63053 63464
SQL 10G>SELECT HEADER_FILE,HEADER_BLOCK,BLOCKS FROM DBA_SEGMENTS WHERE SEGMENT_NAME='T' AND OWNER='TEST';
HEADER_FILE HEADER_BLOCK BLOCKS
----------- ------------ ----------
4 467 8
----------- ------------ ----------
4 467 8
truncate之后虽然segment的位置没有移动,但是data_object_id还是发生变化了。
SQL 10G>alter table t add(b number);
Table altered.
SQL 10G>select object_id,data_object_id from user_objects where object_name='T';
OBJECT_ID DATA_OBJECT_ID
---------- --------------
63053 63464
---------- --------------
63053 63464
我们对t表加一个字段,发现data_object_id没有发生变化,我们可以认为只有当segment发生变化时data_object_id才会随之变化。
[@more@]
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/13444115/viewspace-1050303/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/13444115/viewspace-1050303/