Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do i define autoincrement column in oracle

Status
Not open for further replies.

2314

Programmer
May 19, 2001
69
0
0
IN
How do i define autoincrement column in oracle as i do in sql server with identity column.
 
2314,

Here are some sample structures and invocation that should enhance and illustrate whatever reading you do on the topic of sequences:

Section 1 -- Creating a sequence:
Code:
create sequence seq_2314;

Sequence created.

Section 2 -- Using the sequence (in the table I built for your question regarding "DEFAULT" last night):
Code:
SQL> insert into tab2314 (ID) values (seq_2314.nextval);

1 row created.

SQL> /

1 row created.

SQL> /

1 row created.

SQL> /

1 row created.

SQL> select * from tab2314;

        ID CREATE_DA
---------- ---------
         1 16-NOV-04
         2 16-NOV-04
         3 16-NOV-04
         4 16-NOV-04

5 rows selected.

Does this answer your questions regarding Oracle's counterpart for SQL Server's AUTOINCREMENT column?

[santa]Mufasa
(aka Dave of Sandy, Utah, USA)
e-mail: dave@dasages.com
@ 16:14 (16Nov04) UTC (aka "GMT" and "Zulu"),
@ 09:14 (16Nov04) Mountain Time
 
you probably want to create a before insert trigger to force use of the sequence value. I wouldn't trust the app code/developer but that's just me...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top