我正在执行以下操作:
CREATE TABLE following (
id int(255) auto_increment not null,
user int(255),
followed int(255),
CONSTRAINT pk_following PRIMARY KEY(id),
CONSTRAINT fk_following_users FOREIGN KEY (user), references users(id),
CONSTRAINT fk_followed FOREIGN KEY (followed), references users(id)
) ENGINE = InnoDb;
我收到以下错误:[异常,错误代码30.000,SQLState 42X01]语法错误:遇到"("第2行,第14列。
答案 0 :(得分:0)
int(255)
。那真是怪了。只是做:
CREATE TABLE following (
id int auto_increment not null,
user int,
followed int,
CONSTRAINT pk_following PRIMARY KEY(id),
CONSTRAINT fk_following_users FOREIGN KEY (user) references users(id),
CONSTRAINT fk_followed FOREIGN KEY (followed) references users(id)
) ENGINE = InnoDb;
我还删除了foreign key
定义中不必要的逗号。