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

Home -> Community -> Usenet -> c.d.o.misc -> Re: How to create unique primary index (autoinc feature)?

Re: How to create unique primary index (autoinc feature)?

From: M. Armaghan Saqib <armaghan_at_yahoo.com>
Date: Sat, 22 Jan 2000 09:36:52 GMT
Message-ID: <86btnj$inp$1@nnrp1.deja.com>


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

+---------------------------------------------------------------

| 1. SQL PlusPlus => Add power to SQL Plus command line
| 2. SQL Link for XL => Integrate Oracle with XL
| 3. Oracle CBT with sample GL Accounting System
| Download free: http://www.geocities.com/armaghan/
+---------------------------------------------------------------

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

Original text of this message

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