Missing right parenthesis at create table

52 views Asked by At

I'm trying to create a basic table (Diak) using an SQL script, and it keeps giving me ORA-00907 on the first line.

However, I create another table (Targy) with basically the same structure, and that gets created just fine.

create table Diak (
  Diak_id rowid constraint pk_diak primary key,
  Nev varchar2(100),
  Szul_datum date szul_70_tol constraint check (Szul_datum>= date'1970-1-1'),
  Cim long,
  Kod varchar2(100) constraint uk_diak_kod unique,
  Kezdes_eve number(4) constraint kezdes_88_tol check (Kezdes_eve>= 1988),
  );

create table Targy (
  Targy_id rowid constraint pk_targy primary key ,
  Nev long,
  Kod varchar2(100) constraint uk_targy_kod unique,
  Eloado varchar2(100) default 'Bármi Áron',
  Napok varchar2(100),
  Hely varchar2(100)
  );  

It says "Error starting at line : 1 in command […] 00907. 00000 - "missing right parenthesis" ". Since Targy table is fine, I don't know what the problem is with Diak table.

2

There are 2 answers

0
GMB On BEST ANSWER

You are not declaring the CHECK constraint properly; just remove the xxxxx CONSTRAINT part and you should be fine:

create table Diak (
  Diak_id rowid constraint pk_diak primary key,
  Nev varchar2(100),
  Szul_datum date check (Szul_datum>= date'1970-1-1'),
  Cim long,
  Kod varchar2(100) constraint uk_diak_kod unique,
  Kezdes_eve number(4) check (Kezdes_eve>= 1988)
);

Demo on DB Fiddle.

Note: there is also a trailing comma at the end of the declaration of the last column, but I assume this is a typo.

1
Faceparty On
(Kezdes_eve>= 1988), 

Drop that comma and you should be good to go.