Re: unique column values

From: Jomarlen <jomarlen_at_aol.com>
Date: 1997/09/23
Message-ID: <19970923174701.NAA01087_at_ladder02.news.aol.com>#1/1


You need to create an Oracle sequence.

Create sequence my_sequence
Start with 1;

(Start with is optional - defaults to 1)

You then need to create grants and synonyms exactly as if the sequence is a table (but only grant select)

SELECT my_sequence.nextval from dual;

gives you the next value and increments the sequence geneator.

In SQL*Plus you can use

INSERT INTO my_table(col_1,col_2)

                             VALUES(my_sequence.nextval,'X');

Your sequence column should be number(15)

You could populate the sequence column
with a database trigger, but remember you'll need to either make the column nullable or always pass a dummy value.

You were right not to use ROWID it is
not a fixed value! It changes for instance if you export/import because it maps to
a physical position on the disc.

Regards
John



John C. Lennon
Utility Partners Inc.
4300 West Tropicana Blvd LVO-UPL
Las Vegas NV 89103

FOR UTILITY PARTNERS EMPLOYMENT
OPPORTUNITIES VISIT www.utilpart.com

e-mail: jomarlen_at_aol.com
Web Site: http://members.aol.com/jomarlen/

The views expressed in this message
are those of the author and not
necessarily those of U.P. Inc.
and/or its employees.


Subject: unique column values
From: Ian Douglas <idouglas_at_NLIS.ORG.UK> Date: Tue, 23 Sep 1997 15:55:24 +0100
Message-id: <TI1kxIAch9J0ww7I_at_NLIS.ORG.UK>

I am an Oracle newbie. Could someone please tell me how to create a column with in an Oracle Table that has an automatically unique sequential number. I have looked at the rowid column, but this is no good to me because I need to specify the column name.

Any help in what must surely be a very simple operation would be appreciated.
--
--

Ian Douglas Received on Tue Sep 23 1997 - 00:00:00 CEST

Original text of this message