语法错误:遇到"("第2行,第14列

时间:2017-10-29 16:11:21

标签: php sql netbeans

我正在执行以下操作:

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列。

1 个答案:

答案 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定义中不必要的逗号。