ORA-00907: missing right parenthesis (With Examples)

夙愿已清 提交于 2021-02-10 12:12:24

问题


I'm trying to create this table in SQL.

CREATE TABLE Orders (
    order_id int(10) NOT NULL,
    order_date date NOT NULL,
    total_value varchar(250) DEFAULT NULL,
    order_status varchar(250) DEFAULT NULL,
    payment_type_id int(10) NOT NULL,
    delivery_id int(10) DEFAULT NULL,
    store_id int(10) NOT NULL,
    staff_id int(10) DEFAULT NULL,
    client_id int(10) NOT NULL,
    sale_type_id int(10) NOT NULL
);

I gives me [Err] ORA-00907: missing right parenthesis

I really don't know why. I already searched a lot, I put this example:

CREATE TABLE suppliers (
    supplier_id number(10) NOT NULL,
    supplier_name varchar2(50) NOT NULL,
    contact_name varchar2(50)
);

And it works! But it's the same as mine, so why does it give this error?


回答1:


You dont have to define the length of int. Remove the (10)

CREATE TABLE Orders (
order_id int NOT NULL,
order_date date NOT NULL,
total_value varchar(250) DEFAULT NULL,
order_status varchar(250) DEFAULT NULL,
payment_type_id int NOT NULL,
delivery_id int DEFAULT NULL,
store_id int NOT NULL,
staff_id int DEFAULT NULL,
client_id int NOT NULL,
sale_type_id int NOT NULL
);

SQL FIDDLE DEMO




回答2:


Remove the (10) from all the ints, or change it all to number(10), like so

CREATE TABLE Orders (
order_id int NOT NULL,
order_date date NOT NULL,
total_value varchar(250) DEFAULT NULL,
order_status varchar(250) DEFAULT NULL,
payment_type_id int NOT NULL,
delivery_id int DEFAULT NULL,
store_id int NOT NULL,
staff_id int DEFAULT NULL,
client_id int NOT NULL,
sale_type_id int NOT NULL
);


来源:https://stackoverflow.com/questions/30548888/ora-00907-missing-right-parenthesis-with-examples

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!