Skip to content
Advertisement

I got error on column with identity(1,1)?

Sql developer gives an error of:

ORA-00907: missing right parenthesis, for next table :

create table customer (
    CUSTOMER_ID number identity (1,1) not null,
    CUSTOMER_PHONE char(13) not null
);

Also the ‘identity is red underlined, have no idea why

Advertisement

Answer

Proper syntax for Oracle 12c and newer:

create table customer ( 
  CUSTOMER_ID NUMBER GENERATED ALWAYS AS IDENTITY,
  CUSTOMER_PHONE char(13) not null 
);

-- explicit start and increment
create table customer ( 
  CUSTOMER_ID  NUMBER GENERATED ALWAYS AS IDENTITY(START WITH 1 INCREMENT BY 1),
  CUSTOMER_PHONE char(13) not null 
);

db<>fiddle demo

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement