问题
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