引用时无法在 mysql 中创建 table

Unable to create table in mysql while referencing

CREATE TABLE `DB`.`ORDER` (
    `oid`               INT NOT NULL UNIQUE AUTO_INCREMENT,
    `createdAt`         TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
    `oValue`            FLOAT NOT NULL,
    `no`                INT NOT NULL,
    `qty`               INT NOT NULL,
    `status`            VARCHAR(20) NOT NULL,
    `refundStatus`      VARCHAR(10),
    `refundId`          INT,
    `paymentStatus`     VARCHAR(10),
    `paymentId`         INT,
    `aid`               INT,
    PRIMARY KEY(`oid`),
    FOREIGN KEY `aid` REFERENCES ADDR(`aid`)
)
ENGINE = InnoDB;

ADDR table 键 aid 确实存在于数据库中,但我在 运行 此命令时遇到错误。

错误:

CREATE TABLE `DB`.`ORDER` (
    `oid`               INT NOT NULL UNIQUE AUTO_INCREMENT,
    `createdAt`         TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
    `oValue`            FLOAT NOT NULL,
    `no`                INT NOT NULL,
    `qty`               INT NOT NULL,
    `status`            VARCHAR(20) NOT NULL,
    `refundStatus`      VARCHAR(10),
    `refundId`          INT,
    `paymentStatus`     VARCHAR(10),
    `paymentId`         INT,
    `aid`               INT,
    PRIMARY KEY(`oid`),
    FOREIGN KEY `aid` REFERENCES ADDR(`aid`)
)
ENGINE = InnoDB
MySQL said: Documentation

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'REFERENCES ADDR(`aid`)
)
ENGINE = InnoDB' at line 14

我无法弄清楚为什么在这种情况下会发生,而在其他情况下不会。

替换:

FOREIGN KEY `aid` REFERENCES ADDR(`aid`)

与:

FOREIGN KEY (`aid`) REFERENCES ADDR(`aid`)

或使用官方标准SQL语法:

constraint fk1 FOREIGN KEY (`aid`) REFERENCES ADDR (`aid`)