0
create table participants (
partid number(19) not null primary key auto_increment,
partmn varchar(20) null,
partln varchar(20) null
)

when I am running this code in Oracle it is giving ORA-00907: missing right parenthesis this error after removing auto_increment it is working

Ravi.
  • 674
  • 2
  • 9
  • 21
aman kumar
  • 3,086
  • 1
  • 17
  • 24
  • 1
    Oracle doesn't have auto-increment attribute. However, you can attain the same functionality through sequences. – Ravi. May 03 '14 at 09:14
  • 1
    Possible duplicate: http://stackoverflow.com/questions/11296361/how-to-create-id-with-auto-increment-on-oracle – Ravi. May 03 '14 at 09:16

1 Answers1

0

There is no concept of "auto_increment" or "identity" columns in Oracle. However, you can achive it easily with a sequence.

and after oracle 12 , identity is supported but not auto increment.

use below lines

ALTER TABLE participants ADD (
  CONSTRAINT partid_pk PRIMARY KEY (partid));

CREATE SEQUENCE party_seq;

Trigger definition:

CREATE OR REPLACE TRIGGER party 
BEFORE INSERT ON participants
FOR EACH ROW

BEGIN
  SELECT party_seq.NEXTVAL
  INTO   :new.partid
  FROM   dual;
END;

for oracle 12 and above you can use without triggers like below

CREATE SEQUENCE participants_seq;
CREATE TABLE participants (
  partyId          NUMBER DEFAULT participants _seq.NEXTVAL,
  other column definitions
);
Karibasappa G C
  • 2,686
  • 1
  • 18
  • 27
  • can u tell me how can i do this?? – aman kumar May 03 '14 at 09:14
  • "There is no concept of "identity" columns in Oracle*" - actually there is since 12c: http://docs.oracle.com/cd/E16655_01/server.121/e17906/chapter1.htm#NEWFT158 –  May 03 '14 at 11:50
  • can you please observe this below line in the post which i had answered..after oracle 12 , identity is supported but not auto increment... – Karibasappa G C May 03 '14 at 13:36