ITPub博客

首页 > 应用开发 > IT综合 > Examples of Rowid Use

Examples of Rowid Use

原创 IT综合 作者:tsinglee 时间:2007-11-22 15:13:03 0 删除 编辑

You can use the function SUBSTR to break the data in a rowid into its components. For example, you
can use SUBSTR to break an extended rowid into its four components (database object, file, block,
and row):

SELECT ROWID,
SUBSTR(ROWID,1,6) "OBJECT",
SUBSTR(ROWID,7,3) "FIL",
SUBSTR(ROWID,10,6) "BLOCK",
SUBSTR(ROWID,16,3) "ROW"
FROM products;

ROWID OBJECT FIL BLOCK ROW
------------------ ------ --- ------ ----
AAAA8mAALAAAAQkAAA AAAA8m AAL AAAAQk AAA
AAAA8mAALAAAAQkAAF AAAA8m AAL AAAAQk AAF
AAAA8mAALAAAAQkAAI AAAA8m AAL AAAAQk AAI


Or you can use SUBSTR to break a restricted rowid into its three components (block, row, and file):

SELECT ROWID, SUBSTR(ROWID,15,4) "FILE",
SUBSTR(ROWID,1,8) "BLOCK",
SUBSTR(ROWID,10,4) "ROW"
FROM products;

ROWID FILE BLOCK ROW
------------------ ---- -------- ----
00000DD5.0000.0001 0001 00000DD5 0000
00000DD5.0001.0001 0001 00000DD5 0001
00000DD5.0002.0001 0001 00000DD5 0002


Rowids can be useful for revealing information about the physical storage of a table's data. For
example, if you are interested in the physical location of a table's rows (such as for table
striping), the following query of an extended rowid tells how many datafiles contain rows of a given
table:

SELECT COUNT(DISTINCT(SUBSTR(ROWID,7,3))) "FILES" FROM tablename;

FILES
--------
2

[@more@]

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

上一篇: Restricted Rowids
下一篇: How Rowids Are Used
请登录后发表评论 登录
全部评论
  • 博文量
    740
  • 访问量
    1892746