Re: Using rowid in a html anchor / select statement

From: Thomas J. Kyte <tkyte_at_us.oracle.com>
Date: 1996/09/30
Message-ID: <324fea39.7295740_at_dcsun4>#1/1


On Mon, 30 Sep 1996 21:05:54 -0600, Hans Forbrich <forbrich_at_tibalt.supernet.ab.ca> wrote:

>Brian Martin wrote:
>>
>> Bill Tierney wrote:

 

>> yes. use a key value instead of rowid. it's not a good thing to
>> choose for implementation in a state-dependent situation like
>> a webserver. things could change before the www user sends the
>> updates or whatever. rowid is a fluid value, not a constant
>> like a key.
>
>Agreed ... the ONLY time you can use ROWID and be guaranteed
>of results is during a transaction (before commit) after
>selecting with the 'FOR UPDATE' option. Otherwise you can
>end up pointing to a row that has been moved.
>
>Rowid contains the 'physical' location (file/block/offset) info
>to find a row quickly. After delete, the rowid is meaningless.
>Before insert, it is meaningless. After update is MAY be
>meaningless under a variety of conditions.
>
>Hans

Rowid will never change and is *very* useful in html pages for identifying a row.

True, before insert, a rowid doesn't exist and after a delete it is meaningless (but I can surely say the same exact thing about a primary key. before insert-- meaningless. after delete-- meaningless).

Rowids exist with the row for as long as the row exists. You must delete and then re-insert a row to get a different rowid. Oracle Forms is completely reliant on the rowid and would completely fail if it changed. Oracle basic replication (r/o snapshots) is completely dependent on rowid and would fail if it changed. Oracle indexes are completely dependent on rowid and would fail if it changed (we only update an index entry if you modify the indexed values, we would have to modify an index all the times if the rowid could change (but it can't))

I like to pass rowids from screen to screen (form to form) cause:

  • they are always one column, primary keys can be many columns
  • they never contain special html characters like <, >, &, ", ' ', /, etc (things that can't be in a url)
  • they are the fastest way to get the row back again.
  • They are great for implementing drill down.

Here are some quotes from the doc's on the subject:

<quote>
If a row in a data block is updated so that the overall row lengthincreases and the block’s free space has been completely filled, the datafor the entire row is migrated to a new data block, assuming the entirerow can fit in a new block. Oracle preserves the original row piece of amigrated row to point to the new block containing the migrated row; the ROWID of a migrated row does not change. </quote>

<quote>
The ROWID identifies each row piece by its location or address. Onceassigned, a given row piece retains its ROWID until the correspondingrow is deleted, or exported and imported using the IMPORT andEXPORT utilities. If the cluster key values of a row change, the rowkeeps the same ROWID, but also gets an additional pointer ROWID forthe new values.

Because ROWIDs are constant for the lifetime of a row piece, it isuseful to reference ROWIDs in SQL statements such as SELECT, UPDATE, and DELETE. See “ROWIDs and the ROWID Datatype” onpage 6–9. </quote>

<quote>
A row’s assigned ROWID remains unchanged unless the row isexported and imported (using the IMPORT and EXPORT utilities). When you delete a row from a table (and then commit theencompassing transaction), the deleted row’s associated ROWID can beassigned to a row inserted in a subsequent transaction. </quote>

Thomas Kyte
Oracle Government
tkyte_at_us.oracle.com                          

http://govt.us.oracle.com

  • Check out Oracle Governments web site! ----- Follow the link to "Tech Center" and then downloadable Utilities for some free software...

statements and opinions are mine and do not necessarily reflect the opinions of Oracle Corporation Received on Mon Sep 30 1996 - 00:00:00 CEST

Original text of this message