1. 1、本文档共8页,可阅读全部内容。
  2. 2、有哪些信誉好的足球投注网站(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
Oracle ROWID

Oracle ROWID 我们可能对oracle的rowid的使用并不陌生,不过,如果仔细分析一下,发现其还是有些知识点。 ? ?1、rowid是一个伪列,是用来确保表中行的唯一性,它并不能指示出行的物理位置,但可以用来定位行。 2、rowid是存储在索引中的一组既定的值(当行确定后)。我们可以像表中普通的列一样将它选出来。 3、利用rowid是访问表中一行的最快方式。 4、rowid需要10个字节来存储,显示为18位的字符串。 rowid的组成结构为: data object number(6位字符串)+relative file number(3位字符串)+block number(6位字符串)+row number(3位字符串),如:AAAADeAABAAAAZSAAA 5、我们可以借助oracle提供的包dbms_rowid,来对rowid进行解析从而获取关于行的相关信息: bossdb-SQLselect 2 rowid, 3 dbms_rowid.rowid_object(rowid) obj_id, 4 dbms_rowid.rowid_relative_fno(rowid) df#, 5 dbms_rowid.rowid_block_number(rowid) blknum, 6 dbms_rowid.rowid_row_number(rowid) rowno 7 from p_test where rownum5; ROWID OBJ_ID DF# BLKNUM ROWNO ------------------ ---------- ---------- ---------- ---------- AAAQ+tAANAAAC6SAAA 69549 13 11922 0 AAAQ+tAANAAAC6SAAB 69549 13 11922 1 AAAQ+tAANAAAC6SAAC 69549 13 11922 2 AAAQ+tAANAAAC6SAAD 69549 13 11922 3 我们可以看到,通过rowid_row_number得到的行号是从0开始的,这是和rownum伪列的一个不同之处。我猜测rowid_row_number在求行号的时候是计算首行的偏移量。 一般来说,当表中的行确定后,rowid就不会发生变化。 但当如下情况发生时,rowid将发生改变: 1、对一个表做表空间的移动后 2、对一个表进行了EXP/IMP后 ? ? ? ROWID For each row in the database, the ROWID pseudocolumn returns a rows address. ROWID values contain information necessary to locate a row: * which data block in the data file * which row in the data block (first row is 0) * which data file (first file is 1) In most cases, a ROWID value uniquely identifies a row in the database. However, rows in different tables that are stored together in the same cluster can have the same ROWID. Values of the ROWID pseudocolumn have the datatype ROWID. ROWID values have several important uses: * They are the fastest means of accessing a single row. * They can show you how a tables rows are stored. * They are unique identifiers for rows in a table. A ROWID does not change during the lifetime of its row. However, you should not use ROWID as a tables primary key. If you delete and reinsert a row with the Import and Export utilities, for example, its ROWID ma

文档评论(0)

sb9185sb + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档