Re: Another question Regarding ROWID being Safe

From: Thomas J. Kyte <tkyte_at_us.oracle.com>
Date: 1996/10/25
Message-ID: <32702837.5578271_at_dcsun4>#1/1


On Thu, 24 Oct 1996 09:51:52 -0400, "Brian M. Biggs" <bbiggs_at_cincom.com> wrote:

>stu_at_sierra.net@ wrote:
>>
>> In <326c2aec.94941168_at_dcsun4>, tkyte_at_us.oracle.com (Thomas J. Kyte) writes:
>> >On 22 Oct 1996 02:33:11 GMT, srini_v_at_ix.netcom.com(Srinivasa Rao Vaikuntam)
>> >wrote: <much deleted>
>> >
>> >No, a rowid will not change for a row ever.
>> >
>> >A rowid is assigned when a row is inserted. That rowid will remain with that
>> >row forever while that row exists in the database. When that row is deleted,
>> >that rowid may be reused by some other, newly inserted record.
>> >
>> >Thomas Kyte
>> >Oracle Government
>>
>> I must disagree with your advice. The rowid is there is to provide a unique key.
>> I don't recommend that it be used for anything else. It will change if the row
>> moves for any reason. You should never depend on the physical attributes
>> of the database. Also, some gateways may implement ROWID using some means
>> other than physical location. That is valid as long as the ROWID is unique.
>
>True, the ROWID is there to provide a unique key, and that key can
>change if the rows move. But, I don't see anything wrong with using it

The rowid does NOT change if a rows moves (migrated or chained). A rowid NEVER changes. It is assigned upon insert, it is given back upon delete. An update will never, never cause the rowid to change.

Oracle basic replication (snapshots) count on this. Oracle Forms count on this.
alter table add constraint ... exceptions into count on this.

and so on.

>to immediately update a row. At the same time, I think it would be
>better to always use the true PRIMARY KEY of the table to update the
>database - it seems like the "proper" way to do it. The problem arises
>when you have tables that don't have primary keys. I know that in a
>perfect relational world, ALL tables should have a primary key, but
>sometimes this just isn't practical.
>
>I never thought about the gateways issue, but that makes sense. If you
>start moving to distributed databases, and gateways to other databases,
>the ROWID idea starts to fall apart. Should you ALWAYS have a primary
>key, artificial or real, on every table no matter what the cost, in
>order to facilitate easier updating?
>
>Thanks,
>Brian
>
>--
>Brian M. Biggs mailto:bbiggs_at_cincom.com
>Cincom Systems, Inc. voice: (513) 677-7661
>http://www.cincom.com/

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 Fri Oct 25 1996 - 00:00:00 CEST

Original text of this message