对于我的生活,我不知道为什么 MySQL 不喜欢这个声明:
CREATE TABLE IF NOT EXISTS personnel
(
id INTEGER AUTO_INCREMENT PRIMARY KEY,
firstname VARCHAR(30) NOT NULL,
lastname VARCHAR(30) NOT NULL,
role VARCHAR(50) NOT NULL,
line_manager INTEGER NULL,
FOREIGN KEY (role) REFERENCES roles(name)
ON DELETE CASCADE
ON UPDATE CASCADE,
FOREIGN KEY (line_manager) REFERENCES personnel(id)
ON DELETE CASCADE
ON UPDATE CASCADE
) ENGINE=InnoDB;
插入后 MySQL 的结果输出是ERROR 1064 (42000): 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 'DELETE CASCADE
UPDATE CASCADE,
FOREIGN KEY (line_manager) REFERENCES personnel(id)
' at line 10
.
谁能建议我做错了什么?