简体   繁体   中英

Is there any disadvantage to use rowid in database?

如标题所述,在应用程序中访问数据库时,使用rowid有任何不利之处吗?

Although a rowid uniquely identifies a row in a table, it might change its value if the underlying table is an index organized table or a partitioned table .

Also, rowids change if a table is exported and imported using EXP/IMP.

This implies that rowids should not be stored away for later re-use as the corresponding row then might either not exist or contain completely different data.

不能保证特定行的RowId保持不变,因此最好改用主键。

You're fine to use a ROWID in an application to find a record you were looking at earlier in the same session. Usually this will be the quickest way to get to the record.

However, what you should never do is then store this Rowid in the database - or anywhere else - as restores from backup and so on can change ROWIDs.

If you're using Oracle, use the UROWID - Universal ROWID - as this will stop using Physical ROWIDs and start using Logical ROWIDs on tables where the ROWID might change during a session, for example on an index organized table.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM