Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: SQL Server 7 vs Oracle regarding IDENTITY

Re: SQL Server 7 vs Oracle regarding IDENTITY

From: Sybrand Bakker <postbus_at_sybrandb.demon.nl>
Date: Sun, 1 Apr 2001 22:06:38 +0200
Message-ID: <tcf2eicjl6sd16@beta-news.demon.nl>

"Moshe Solomon" <moshe_at_impactinfosys.com> wrote in message news:tcf23mjgngoocd_at_corp.supernews.com...
> I'm very familiar with SQL Server 7. How do I duplicate the IDENTITY
 concept
> to Oracle. I know there is something called ROWID, but I'm unsure how this
> works. Do I need to create a field specifically for the row id as I would
 in
> SQL Server, or does each row in a table in Oracle have this attribute
> automatically. Can I reference this ROWID in my procedures? I'm very new
 to
> Oracle, so please be patient.
>
> Regards,
> MS
>
>

Rowid is the internal Oracle identification of a row. It cannot be compared with the identity concept. You would also be wise to use it never in any procedure. In Oracle 7 you could be sure the rowid didn't change for the live of a row, in Oracle 8 with partitioning enabled you can't. You need to use a feature of Oracle which is called sequence. A sequence can be used everywhere and is not bound to a specific table. Your 'identity' column would typically be set using a before insert for each row trigger
using
select <sequence>.nextval
into :new.<identity column>
from dual;

Further discussions in the Oracle Application Developers Guide.

Hth,

Sybrand Bakker, Oracle DBA Received on Sun Apr 01 2001 - 15:06:38 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US