右括号错误?

时间:2018-04-28 06:13:43

标签: sql oracle

create table sales_order(
    order_no varchar2(6) Primary Key check(order_no like 'O%'),
    order_date date,
    client_no varchar2(6) foreign key references client_master(client_no),
    dely_address varchar2(25),
    salesman_no varchar2(6) foreign key references salesman_master(salesman_no),
    dely_type char(1) default 'F' check(dely_type like 'F' OR dely_type like 'P'),
    billed_yn char(1),
    dely_date date check (dely_date > order_date),
    order_status varchar2(10) check(order_status IN ('In Process','Fulfilled','BackOrder','Cancelled'))
);

当我尝试执行此查询时,它会显示

  

ORA-00907:缺少右括号。不知道哪里缺少右括号。

1 个答案:

答案 0 :(得分:0)

使用此查询将三个约束移到最后:

    create table sales_order(
    order_no varchar2(6) Primary Key check(order_no like 'O%'),
    order_date date,
    client_no varchar2(6) ,
    dely_address varchar2(25),
    salesman_no varchar2(6) ,
    dely_type char(1) default 'F' check(dely_type like 'F' OR dely_type like 'P'),
    billed_yn char(1),
    dely_date date,
    order_status varchar2(10) check(order_status IN ('In Process','Fulfilled','BackOrder','Cancelled')),
    constraint sales_fk foreign key(client_no) references client_master(client_no),
    constraint salesman_fk foreign key(salesman_no) references salesman_master(salesman_no),
    constraint dely_date_ck check (dely_date > order_date)
);