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.
  • 646
  • 2
  • 8
  • 20
aman kumar
  • 2,848
  • 1
  • 14
  • 22
  • 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,644
  • 1
  • 17
  • 26