Siddarth Sanjay
Siddarth Sanjay

Reputation: 1

MySQL issue while creating a table

This is my SQL code I am trying to solve

create table Sales_Order
(
    orderno varchar2(6) primary key check(orderno like 'O%'),
    clientno varchar(6),
    foreign key references Cust_Master(clientno),
    orderdate date not null,
    delytype char(1) check(delytype in ('P','F')) default 'F',
    billyn char(1),
    payment_mode varchar2(15)
    check(payment_mode in ('COD', 'Net Banking', 'Credit Card', 'Debit Card')),
    delydate date,
    orderstatus varchar2(10) 
    check(orderstatus in ('In Process', 'Fulfilled', 'BackOrder', 'Cancelled')
);

I am getting an error at line 1:

ORA-00906: missing left parenthesis

Upvotes: 0

Views: 33

Answers (1)

The Impaler
The Impaler

Reputation: 48770

The syntax you are using is incorrect according to Oracle database. There are a few typos, a wrong syntax for a FK and wrong location of the DEFAULT clause. In short, you should use:

create table Sales_Order (
  orderno varchar2(6) primary key check(orderno like 'O%'),
  clientno varchar(6) references Cust_Master (clientno),
  orderdate date not null,
  delytype char(1) default 'F' check(delytype in ('P','F')),
  billyn char(1),
  payment_mode varchar2(15)
    check(payment_mode in ('COD', 'Net Banking', 'Credit Card', 'Debit Card')),
  delydate date,
  orderstatus varchar2(10) 
    check(orderstatus in ('In Process', 'Fulfilled', 'BackOrder', 'Cancelled'))
);

See running example at db<>fiddle.

Upvotes: 1

Related Questions