我正在尝试使用以下内容创建一个新表:
CREATE TABLE onsale (
id INT AUTO_INCREMENT,
name VARCHAR(255),
desc TEXT,
image_file VARCHAR(255)
);
但是,我不断收到错误消息:
ERROR 1064: (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB version for the right syntax to use near: 'desc TEXT, image_file VARCHAR(255))' at line 1
我看不出我的语法有什么问题。对我来说似乎没问题(显然)。
你能告诉我我做错了什么吗?
感谢您的帮助。
答案 0 :(得分:2)
您用于列 desc
的名称是保留字。您还需要primary key (id)
:
CREATE TABLE onsale (
id INT AUTO_INCREMENT,
name VARCHAR(255),
description TEXT,
image_file VARCHAR(255),
primary key (id)
);