[Err] 1005 - Can't create table 'o2o.tb_product' (errno: 121)
来源:2-4 实体类设计与表创建C
ilhp_henu
2019-02-24
[SQL] CREATE TABLE IF NOT EXISTS tb_product
(product_id
int(100) NOT NULL AUTO_INCREMENT,product_name
varchar(100) NOT NULL,product_desc
varchar(2000) DEFAULT NULL,img_addr
varchar(2000) DEFAULT ‘’,normal_price
varchar(100) DEFAULT NULL,promotion_price
varchar(100) DEFAULT NULL,priority
int(2) NOT NULL DEFAULT ‘0’,create_time
datetime DEFAULT NULL,last_edit_time
datetime DEFAULT NULL,enable_status
int(2) NOT NULL DEFAULT ‘0’,product_category_id
int(11) DEFAULT NULL,shop_id
int(20) NOT NULL DEFAULT ‘0’,
PRIMARY KEY (product_id
),
CONSTRAINT fk_product_procate
FOREIGN KEY (product_category_id
) REFERENCES tb_product_category
(product_category_id
),
CONSTRAINT fk_product_shop
FOREIGN KEY (shop_id
) REFERENCES tb_shop
(shop_id
)
) ENGINE=InnoDB AUTO_INCREMENT=16 DEFAULT CHARSET=utf8;
[Err] 1005 - Can’t create table ‘o2o.tb_product’ (errno: 121)
1回答
-
翔仔
2019-02-25
同学好,请确保其他与之相关联的表已经创建出来了,CONSTRAINT fk_product_procate FOREIGN KEY (product_category_id) REFERENCES tb_product_category (product_category_id),
CONSTRAINT fk_product_shop FOREIGN KEY (shop_id) REFERENCES tb_shop (shop_id)tb_product_category和tb_shop 并且相关键位的名字不重复
00
相似问题
回答 2