Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: How to create unique primary index (autoinc feature)?
Oracle does not support any auto-increment column.
You can use my SQL PlusPlus (freeware) to generate the following code to implement auto-in column in the database.
Here is an example:
SQL> EXEC S2.bldseq('seq_deptno','ORACLE','dept','deptno')
| DROP SEQUENCE seq_deptno;
| CREATE SEQUENCE seq_deptno
| START WITH 1 INCREMENT BY 1
| MINVALUE 1 MAXVALUE 999999999999999999999999999
| CYCLE CACHE 20 ORDER;
|
| -- This optional trigger applies sequence values to a table column
thus
| -- creating an auto-increment column which can be used as primary-key
|
| CREATE OR REPLACE TRIGGER trg1_dept
| BEFORE INSERT
| ON dept
| FOR EACH ROW
| BEGIN
| SELECT seq_deptno.NEXTVAL
| INTO :NEW.deptno
| FROM DUAL;
| END;
| /
regards,
M. Armaghan Saqib
+---------------------------------------------------------------| 2. SQL Link for XL => Integrate Oracle with XL
| 1. SQL PlusPlus => Add power to SQL Plus command line
+---------------------------------------------------------------
In article <86bq2k$1iog$1_at_dolf.netfront.net>, "Torsetn Trzeciak" <torsten.trzeciak_at_gmx.de> wrote:
> Hello, > I use JDBC with Oracle in a multi user environment. > How can I create a unique primary key for inserts. > Is there an autoincrement feature available? > > Thanks in advance > Torsten > > ------ > Posted via news://freenews.netfront.net > Complaints to news_at_netfront.net
Sent via Deja.com http://www.deja.com/
Before you buy.
Received on Sat Jan 22 2000 - 03:36:52 CST
![]() |
![]() |