Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sqlite/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql 将新数据插入表时出现语法错误_Sql_Sqlite - Fatal编程技术网

Sql 将新数据插入表时出现语法错误

Sql 将新数据插入表时出现语法错误,sql,sqlite,Sql,Sqlite,当我试图向表中插入新条目时,我总是遇到语法错误,但我似乎不知道为什么。 首先,这里是.schema: CREATE TABLE collection ( id int primary key not null, album text not null, artist text not null, year int not null, cover text ); 这是我用来添加条目的行: sqlite> insert into collection(115,"houses of the

当我试图向表中插入新条目时,我总是遇到语法错误,但我似乎不知道为什么。 首先,这里是.schema:

CREATE TABLE collection (
id int primary key not null,
album text not null,
artist text not null,
year int not null,
cover text 
);
这是我用来添加条目的行:

sqlite> insert into collection(115,"houses of the holy","led zeppelin", 1973, "junk");
所有值都匹配:id int、唱片集文本、艺术家文本、年份int、封面文本。但终端只是吐出以下语法错误:

Error: near "115": syntax error
我还测试了将int值放在引号内,但最终得到的结果是:

Error: near ";": syntax error

有人能帮我找出我做错了什么吗?

此语法不正确:

insert into collection(115,"houses of the holy","led zeppelin", 1973, "junk")
首先,使用单引号而不是双引号:

insert into collection (115, 'houses of the holy', 'led zeppelin', 1973, 'junk')
除此之外,查询解析器希望这些值是列名,而它们作为列名无效。您应该能够简单地包含
关键字:

INSERT INTO collection VALUES (115, 'houses of the holy', 'led zeppelin', 1973, 'junk')
否则,请显式指定列名:

INSERT INTO collection (id, album, artist, year, cover) VALUES (115, 'houses of the holy', 'led zeppelin', 1973, 'junk')

此语法不正确:

insert into collection(115,"houses of the holy","led zeppelin", 1973, "junk")
首先,使用单引号而不是双引号:

insert into collection (115, 'houses of the holy', 'led zeppelin', 1973, 'junk')
除此之外,查询解析器希望这些值是列名,而它们作为列名无效。您应该能够简单地包含
关键字:

INSERT INTO collection VALUES (115, 'houses of the holy', 'led zeppelin', 1973, 'junk')
否则,请显式指定列名:

INSERT INTO collection (id, album, artist, year, cover) VALUES (115, 'houses of the holy', 'led zeppelin', 1973, 'junk')

您缺少
关键字

INSERT INTO table_name
VALUES (value1,value2,value3,...);

有关更多信息,请参见您缺少
关键字

INSERT INTO table_name
VALUES (value1,value2,value3,...);

有关更多信息,请参见

您使用的是双引号而不是单引号。您使用的是双引号而不是单引号。