MARIADB ERROR 1064(42000)当CREATE TABLE时

时间:2016-11-25 08:08:23

标签: mysql sql mariadb ddl create-table

当我尝试创建表格时:

MariaDB [heladeria]> create table sabores ('Id_sabores' int NOT
NULL,'sab_nombre' varchar(255) NOT NULL, 'calorias' varchar(255) NOT
NULL, PRIMARY KEY (Id_sabores));

我收到以下错误:

ERROR 1064 (42000): You have an error
in your SQL syntax; check the manual that corresponds to your MariaDB
server version for the right syntax to use near ''Id_sabores' int NOT
NULL,'sab_nombre' varchar(255) NOT NULL, 'calorias' varchar' at line 1

1 个答案:

答案 0 :(得分:2)

单引号(')用于表示字符串文字,而不是对象(在本例中为列)名称。只需删除它们就可以了:

create table sabores (
    Id_sabores int NOT NULL,
    sab_nombre varchar(255) NOT NULL, 
    calorias varchar(255) NOT NULL, 
    PRIMARY KEY (Id_sabores)
);