Mysql数据库创建表出错 50
--4创建订单表请大神修改!--1.订单表CREATETABLEorders(oidVARCHAR(32)PRIMARYKEYNOTNULL,ordertimeDATET...
--4创建订单表请大神修改!--1.订单表 CREATE TABLE orders (
oid VARCHAR(32) PRIMARY KEY NOT NULL,
ordertime DATETIME DEFAULT NULL,
total DOUBLE DEFAULT NULL,
state INT(11) DEFAULT NULL,
address VARCHAR(30) DEFAULT NULL,
NAME VARCHAR(20) DEFAULT NULL,
telephone VARCHAR(20) DEFAULT NULL,
uid VARCHAR(32) DEFAULT NULL,
KEY order_fk_0001 (uid),
CONSTRAINT order_fk_0001 FOREIGN KEY (uid) REFERENCES USER (uid))ENGINE=INNODB DEFAULT CHARSET=utf8;
--2.订单项表
CREATE TABLE orderitem (
itemid VARCHAR(32) PRIMARY KEY NOT NULL ,
COUNT INT(11) DEFAULT NULL,subtotal DOUBLE DEFAULT NULL,
pid VARCHAR(32) DEFAULT NULL,
oid VARCHAR(32) DEFAULT NULL,
KEY order_item_fk_0001 (pid),
KEY order_item_fk_0002 (oid),
CONSTRAINT order_item_fk_0001 FOREIGN KEY (pid) REFERENCES product (pid),
CONSTRAINT order_item_fk_0002 FOREIGN KEY (oid) REFERENCES orders (oid))ENGINE=INNODB DEFAULT CHARSET=utf8; 展开
oid VARCHAR(32) PRIMARY KEY NOT NULL,
ordertime DATETIME DEFAULT NULL,
total DOUBLE DEFAULT NULL,
state INT(11) DEFAULT NULL,
address VARCHAR(30) DEFAULT NULL,
NAME VARCHAR(20) DEFAULT NULL,
telephone VARCHAR(20) DEFAULT NULL,
uid VARCHAR(32) DEFAULT NULL,
KEY order_fk_0001 (uid),
CONSTRAINT order_fk_0001 FOREIGN KEY (uid) REFERENCES USER (uid))ENGINE=INNODB DEFAULT CHARSET=utf8;
--2.订单项表
CREATE TABLE orderitem (
itemid VARCHAR(32) PRIMARY KEY NOT NULL ,
COUNT INT(11) DEFAULT NULL,subtotal DOUBLE DEFAULT NULL,
pid VARCHAR(32) DEFAULT NULL,
oid VARCHAR(32) DEFAULT NULL,
KEY order_item_fk_0001 (pid),
KEY order_item_fk_0002 (oid),
CONSTRAINT order_item_fk_0001 FOREIGN KEY (pid) REFERENCES product (pid),
CONSTRAINT order_item_fk_0002 FOREIGN KEY (oid) REFERENCES orders (oid))ENGINE=INNODB DEFAULT CHARSET=utf8; 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询