Oracle ROWID
时间:2010-12-03 来源:ank
SQL> set autotrace off
SQL> select rowid from hr.employees;
ROWID
-----------
AAAMg3AAFAAAABYABa
AAAMg3AAFAAAABYAAg
AAAMg3AAFAAAABYAAp
AAAMg3AAFAAAABYABf
AAAMg3AAFAAAABYAAG
AAAMg3AAFAAAABUAAI
AAAMg3AAFAAAABYABH
AAAMg3AAFAAAABYABQ
...
107 rows selected.
rowid格式如下:
AAAPW1--->数据对象编号
AAL--->文件编号
AAAAA1--->块编号
AAA---->行号
通过dbms_rowid包,直接得到具体的rowid包含的信息
SQL> select dbms_rowid.rowid_object(rowid) object_id,
2 dbms_rowid.rowid_relative_fno(rowid) file_id,
3 dbms_rowid.rowid_block_number(rowid) block_id,
4 dbms_rowid.rowid_row_number(rowid) num
5 from scott.dept;
OBJECT_ID FILE_ID BLOCK_ID NUM
---------- ---------- ---------- ----------
51146 4 16 0
51146 4 16 1
51146 4 16 2
51146 4 16 3
知道object_id,查找具体的信息
SQL> select OBJECT_NAME from dba_objects where OBJECT_ID=51146;
OBJECT_NAME
----------------
DEPT
知道file_id,查找具体的信息
SQL>select name,file#,ts# from v$datafile;