CREATE TABLE product (
id INTEGER UNSIGNED AUTO_INCREMENT,
name VARCHAR(50),
weight FLOAT,
fat FLOAT,
protein FLOAT,
carbohydrates FLOAT,
PRIMARY KEY (id)
);
当我用外键创建新表时发生错误。
CREATE TABLE saleline (
id INTEGER UNSIGNED AUTO_INCREMENT,
product_id INTEGER,
PRIMARY KEY (id),
FOREIGN KEY (product_id) REFERENCES
product(id));
这是错误消息:
错误1215(HY000):无法添加外键约束
该如何解决?
答案 0 :(得分:1)
添加外键时,它应该具有相同的类型select python interpreter
INTEGER UNSIGNED