Database autoincrement columns : howto do do them?

Carl Sappenfield CSAPPENFIELD at kc.rr.com
Sun Jul 21 18:24:13 CDT 2002


You could use sequences in Oracle:

CREATE SEQUENCE myseq 
  start with 1
  increment by 1;;

INSERT INTO mytable
  (myseq.next_val, ... )

----- Original Message ----- 
From: "Hanasaki JiJi" <hanasaki at hanaden.com>
To: "KCLUG" <kclug at kclug.org>
Sent: Saturday, July 20, 2002 10:24 AM
Subject: Database autoincrement columns : howto do do them?

> Sorry for being a bit off the Linux topic ...
> 
> I remember someone was talking to me at the meeting after the meeting 
> and seemed to be an Oracle Guru!
> 
> Is there anyway to acheive:
> Database independant way to do autoincrement columns
> If not Database Independant, how about just for Oracle?
> 
> Triggers have been suggested; however I would like to stay away from 
> stored procedures.
> 
> Someone also suggested:
> INSERT INTO [table] (ID, cols..) VALUES (MAX(ID)+1, ....);
> <ID is an INT, PRIMARYKEY, with UNIQUE INDEX>
> 
> Development has been done on a small RDBMS that support they key 
> "IDENTITY" for a column type.  This results in an INT/PRIMARYKY that 
> autoincs on insert.
> 
> Thank you.
> 
> 
> 
> 




More information about the Kclug mailing list