什么会导致 Oracle ROWID 更改?
AFAIK Oracle 中的 ROWID 表示相应数据文件中记录的物理位置。 在什么情况下记录的ROWID可能会改变?
我所知道的一个是分区表上的更新,它将记录“移动”到另一个分区。
还有其他情况吗? 我们的大多数数据库都是 Oracle 10。
AFAIK ROWID in Oracle represents physical location of a record in appropriate datafile.
In which cases ROWID of a record may change ?
The one known to me is UPDATE on partitioned table that "moves" the record to another partition.
Are there another cases ? Most of our DBs are Oracle 10.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
正如您所说,只要在磁盘上物理移动行,就会发生这种情况,例如:
如果位于索引组织表中,则对主键的更新也会为您提供不同的 ROWID。
As you have said, it occurs anytime the row is physically moved on disk, such as:
If is in an index organized table, then an update to the primary key would give you a different ROWID as well.
WW 的另一个+1,但只是添加一点额外的...
如果主要问题是您是否可以存储 ROWID 供以后使用,我会说“不要这样做”。
您可以在事务中使用 ROWID - 例如收集一组 ROWID 来执行后续操作 - 但您不应该将 ROWID 存储在表中并假设它们将以后使用就可以了。
Another +1 to WW, but just to add a little extra...
If the driving question is whether you can store ROWIDs for later use, I would say "don't do it".
You are fine to use ROWIDs within a transaction - for example collecting a set of ROWIDs on which to carry out a subsequent operations - but you should never store the ROWIDs in a table and assume they're going to be ok to use at a later date.
+1 @WW
顺便说一句:
索引组织表的 ROWID 是不同的(我相信它们被称为 UROWID),因为行的物理位置可以在表更新期间发生变化(当树节点拆分或连接时)。
为了使索引仍然可行,UROWID 包括“逻辑 id”(主键)和“可能的物理 id”(常规 ROWID),后者可能已过期。
+1 @WW
As an aside:
ROWID for index organized tables are different (they are called UROWID, I believe), because the physical location of the row can change during updates to the table (when tree nodes split or are joined).
In order to make indexing still possible, the UROWID includes the "logical id" (the primary key), and the "likely physical id" (a regular ROWID), the latter of which may be expired.