[42000][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
'rank INT(3) DEFAULT 0, remark VARCHAR(500), ' at line 18
CREATE TABLE admin (
id INTEGER NOT NULL AUTO_INCREMENT,
created_date DATETIME,
last_modified_date DATETIME,
avatar VARCHAR(1000),
display INT(1) DEFAULT 0,
first_login INT(1) DEFAULT 1,
inviter_id INTEGER,
last_login_time DATETIME,
level INT(3) DEFAULT 0,
locked_date DATETIME,
mail VARCHAR(255),
nickname VARCHAR(50),
password VARCHAR(100) NOT NULL,
password_attempt_count INT(3) DEFAULT 0,
phone VARCHAR(20),
pid INTEGER,
`rank` INT(3) DEFAULT 0, -- 使用反引号转义保留关键字
remark VARCHAR(500),
score INT(11) DEFAULT 0,
status INT(1) DEFAULT 1,
update_password_time DATETIME,
username VARCHAR(50) NOT NULL,
we_chat_open_id VARCHAR(150),
PRIMARY KEY (id)
) ENGINE=MyISAM;
解决这个问题的方式是对 rank 字段进行转义,用反引号 (``) 包裹字段名,以避免与保留关键字冲突。
文心一言、豆包、智谱清言、ChatGPT回答正确。