为什么外键让我头疼?
首先我创建了数据库名称,colorcode
然后创建了paper
工作正常的表:
CREATE TABLE paper (
paper_id int(20) NOT NULL,
description VARCHAR(40) NOT NULL,
paper_color VARCHAR(40) NOT NULL,
PRIMARY KEY (paper_id, paper_color)
) ENGINE=InnoDB;
然后brick
表
CREATE TABLE brick(
brick_id int(20) NOT NULL,
description varchar(40) NOT NULL,
brick_color varchar (40) NOT NULL,
PRIMARY KEY (brick_id),
FOREIGN KEY (brick_color) REFERENCES paper(paper_color)
) ENGINE=InnoDB;
这不是=>
#1005 - Can't create table 'colorcode.brick' (errno: 150)
谢谢您的帮助