什么会导致 Oracle ROWID 更改?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/435109/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What can cause an Oracle ROWID to change?
提问by Dmitry Khalatov
AFAIK ROWID in Oracle represents physical location of a record in appropriate datafile. In which cases ROWID of a record may change ?
Oracle 中的 AFAIK ROWID 表示适当数据文件中记录的物理位置。在哪些情况下记录的 ROWID 可能会改变?
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.
还有其他情况吗?我们的大多数数据库都是 Oracle 10。
回答by WW.
As you have said, it occurs anytime the row is physically moved on disk, such as:
正如您所说,该行在磁盘上物理移动的任何时候都会发生,例如:
- Export/import of the table
- ALTER TABLE XXXX MOVE
- ALTER TABLE XXXX SHRINK SPACE
- FLASHBACK TABLE XXXX
- Splitting a partition
- Updating a value so that it moves to a new partition
- Combining two partitions
- 表格的导出/导入
- 更改表 XXXX 移动
- 更改表 XXXX 收缩空间
- 闪回表XXXX
- 拆分分区
- 更新值以使其移动到新分区
- 合并两个分区
If is in an index organized table, then an update to the primary key would give you a different ROWID as well.
如果在索引组织的表中,那么对主键的更新也会为您提供不同的 ROWID。
回答by Thilo
+1 @WW
+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).
索引组织表的 ROWID 是不同的(我相信它们被称为 UROWID),因为行的物理位置可以在更新表的过程中发生变化(当树节点分裂或连接时)。
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.
为了使索引仍然可能,UROWID 包括“逻辑 ID”(主键)和“可能的物理 ID”(常规 ROWID),后者可能已过期。
回答by Nick Pierpoint
Another +1 to WW, but just to add a little extra...
WW 的另一个 +1,但只是为了增加一点额外的...
If the driving question is whether you can store ROWIDs for later use, I would say "don't do it".
如果驱动问题是您是否可以存储 ROWID 以备后用,我会说“不要这样做”。
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 neverstore the ROWIDs in a table and assume they're going to be ok to use at a later date.
您可以在事务中使用 ROWID - 例如收集一组用于执行后续操作的 ROWID - 但您永远不应该将 ROWID 存储在表中并假设它们以后可以使用日期。