Xiaowei
Xiaowei

Reputation: 73

Is there any disadvantage to use rowid in database?

As captioned, when accessing database in application, is there any disadvantage to use rowid?

Upvotes: 2

Views: 1115

Answers (3)

David Webb
David Webb

Reputation: 193716

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.

Upvotes: 0

Learning
Learning

Reputation: 8185

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.

Upvotes: 3

Jesse Weigert
Jesse Weigert

Reputation: 4854

RowId is not guaranteed to stay the same for a particular row, so it's best to use a primary key instead.

Upvotes: 1

Related Questions