ROWID的组成ROWID字段由18个字符组成,如: OOOOOOFFFBBBBBBRRROOOOOO表示数据库对象编号FFF表空间中的数据文件编号BBBBBB存储记录的数据块的编号RRR标示同一数据块中不同的记录样例:AAAAVJAAEAAAABEAAA
SELECT ROWID, ENAMEFROM EMPWHERE EMPNO = 7369;Output:ROWID ENAMEAAAR3sAAEAAAACXAAA SMITH
ROWID是否可以用在Where条件中ROWID可以作为WHERE条件来查询记录,但因为记录物理位置是可能发生变化的,所以在程序中用ROWID查询数据是一个不靠谱的事情。SELECT * FROM EMP WHERE ROWID = "AAAR3sAAEAAAACXAAA'
ROWID什么情况会发生变化Doing an export or import of the table
Doing ALTER TABLE XXXX MOVE
Doing ALTER TABLE XXXX SHRINK SPACE
Doing FLASHBACK TABLE XXXX
When splitting a partition
When updating a value so that it moves to a new partition
Row Piece in a Database Block
ROWID in B-Tree Index< http://www.2cto.com/kf/ware/vc/" target="_blank" class="keylink">vc3Ryb25nPjxpbWcgZGF0YS1waW5pdD0="registered" src="https://www.cppentry.com/upload_files/article/57/1_14pux__.png" alt="\" />
在B-Tree索引的叶子节点,不光存放了索引列值,还保存这个列值所对应的的ROWID,以便快速定位。一个查询过程如:

上图的SQL语句查找location_id为1800的行。首先在映射表中找到1800对应的physical rowid,再通过physical rowid找到对应的logical rowid,再通过logical rowid在IOT表中找到对应的行。
ROWID vs ROWNUMROWID is the unique physical address of every row of a table maintained by database automatically. ROWNUM is the sequential number allocated to each row in the result set object during query execution.
ROWID is permanent whereas ROWNUM is temporary. ROWID is 16-bit hexadecimal whereas ROWNUM is numeric.