我是SQL的新手,我似乎找不到为什么我会遇到此错误(缺少正确的括号)
这是我要创建的桌子,但我得到了这个错误
第7/34行中的错误:ORA-00907:缺失右括号ORA-06512:在“ SYS.WWV_DBMS_SQL_SQL_PAPEX_220100”,第847行ORA-06512:at“ 。
- 行数int int int int int
- not not not null, list_price Decimal(10,2)不是零,
- 折扣十进制(4,2)NOT NULL默认默认值0,
- 主键(Item_id),efirene_id(item_id),
- extir keir(item_id) key(order_id)参考订单(order_id),“
这是代码:
CREATE TABLE order_items (
order_id INT,
item_id INT,
product_id INT NOT NULL,
quantity INT NOT NULL,
list_price DECIMAL(10 , 2 ) NOT NULL,
discount DECIMAL(4 , 2 ) NOT NULL DEFAULT 0,
PRIMARY KEY (order_id , item_id),
FOREIGN KEY (order_id)
REFERENCES orders (order_id),
FOREIGN KEY (product_id)
REFERENCES products (product_id)
);
this is the table I am trying to create but I get this error
Error at line 7/34: ORA-00907: missing right parenthesis ORA-06512: at "SYS.WWV_DBMS_SQL_APEX_220100", line 847 ORA-06512: at "SYS.DBMS_SYS_SQL", line 1658 ORA-06512: at "SYS.WWV_DBMS_SQL_APEX_220100", line 833 ORA-06512: at "APEX_220100.WWV_FLOW_DYNAMIC_EXEC", line 1903
- quantity INT NOT NULL,
- list_price DECIMAL (10, 2) NOT NULL,
- discount DECIMAL (4, 2) NOT NULL DEFAULT 0,
- PRIMARY KEY (item_id),
- FOREIGN KEY (order_id) REFERENCES orders (order_id),"
This is the code:
CREATE TABLE order_items (
order_id INT,
item_id INT,
product_id INT NOT NULL,
quantity INT NOT NULL,
list_price DECIMAL(10 , 2 ) NOT NULL,
discount DECIMAL(4 , 2 ) NOT NULL DEFAULT 0,
PRIMARY KEY (order_id , item_id),
FOREIGN KEY (order_id)
REFERENCES orders (order_id),
FOREIGN KEY (product_id)
REFERENCES products (product_id)
);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有了约束,
默认
首先,不是null
next(请参阅第7行):With constraints,
default
goes first,not null
next (see line #7):