Dinesh Soni
Dinesh Soni

Reputation: 19

ORA-00907: missing right parenthesis Error while creating a table on oracle

I am getting ORA-00907: missing right parenthesis Error while creating a table on oracle

here is what I did:

create table customers(
cust_num number(4),
company varchar2(20),
cust_rep number(3),
credit_limit number(15),
custraint cust_num_pk
primary key(cust_num));

whats wrong ??

Upvotes: 0

Views: 12113

Answers (3)

Sasanka Panguluri
Sasanka Panguluri

Reputation: 3128

There's nothing called Custraint. It's Constraint.

It should be:

create table customers(
  cust_num number(4),
  company varchar2(20),
  cust_rep number(3),
  credit_limit number(15),
  constraint cust_num_pk primary key(cust_num)
);

Upvotes: 6

Sunil Khatri
Sunil Khatri

Reputation: 46

Check your syntax, see the below statement works fine,

  create table customers( cust_num number(4), company varchar2(20),
  cust_rep number(3), credit_limit number(15), constraint cust_num_pk 
  primary key(cust_num));

Upvotes: 0

Aditya Kakirde
Aditya Kakirde

Reputation: 5225

You can also create a primary key constraint like -

create table customers( cust_num number(4) primary key, company varchar2(20), cust_rep number(3), credit_limit number(15));

This is called column-level constraint definition, while the ones in above posts are known as Table-level constraint definitions.

Both are correct.

Upvotes: 0

Related Questions