sql语句
CREATE TABLE orderitem (
iid CHAR(32) PRIMARY KEY,/主键/
count
INT,/数量/orderitem
subtotal DECIMAL(10,0),/小计/
oid CHAR(32),/所属订单/
bid CHAR(32),/订单项所指的商品/
FOREIGN KEY (oid) REFERENCES orders (oid),/建立主外键关系/
FOREIGN KEY (bid) REFERENCES book (bid)/建立主外键关系/
);
报错如下:
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'subtotal DECIMAL(10,0),
oid CHAR(32),
bid CHAR(32),
FOREIGN KEY (oid) REFE' at line 4
数据库版本 mysql-5.5.60-winx64
不知道怎么回事,请大神赐教!
相关问题
- sqlyog export query result as csv
- NOT DISTINCT query in mySQL
- MySQL: conduct a basic search
- Why sometimes there is one of more gap(s) in the v
- mySQL alter table on update, current timestamp
把前面多了个orderitems,去掉应该可以了
mysql> CREATE TABLE orderitem (
-> iid CHAR(32) PRIMARY KEY,/主键/
-> COUNT INT,/数量/
-> subtotal DECIMAL(10,0),/小计/
-> oid CHAR(32),/所属订单/
-> bid CHAR(32),/订单项所指的商品/
-> FOREIGN KEY (oid) REFERENCES orders (oid),/建立主外键关系/
-> FOREIGN KEY (bid) REFERENCES book (bid)/建立主外键关系/
-> );
Query OK, 0 rows affected (0.16 sec)
你把每行后面的/后面的东西去了试试
你后面的中文应该是注释吧?请用下面的语法:
CREATE TABLE orderitem (
iid CHAR(32) PRIMARY KEY COMMENT '主键',
count INT COMMENT '数量',
subtotal DECIMAL(10,0) COMMENT '小计',
oid CHAR(32) COMMENT '所属订单',
bid CHAR(32) COMMENT '订单项所指的商品',
FOREIGN KEY (oid) REFERENCES orders (oid) COMMENT '建立主外键关系',
FOREIGN KEY (bid) REFERENCES book (bid) COMMENT '建立主外键关系'
);
varchar?
先把所以中午删除掉执行下试试,如果行,再添加上