我是 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 'rank INTEGER, year INTEGER, description TEXT, PRIMARY KEY(position_id), ' at line 4
创建调用是
CREATE TABLE Position (
position_id INTEGER NOT NULL AUTO_INCREMENT,
profile_id INTEGER,
rank INTEGER,
year INTEGER,
description TEXT,
PRIMARY KEY(position_id),
CONSTRAINT position_ibfk_1
FOREIGN KEY (profile_id)
REFERENCES Profile (profile_id)
ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
一切看起来都很干净,所以我不确定为什么会收到此错误
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
根据 P.Salmon 的说法,这是因为等级的名称。查看 dev.mysql.com/doc/refman/8.0/en/keywords.html 后,将排名更改为
rank并且成功了。