在Windiws PowerShell中使用sqlite3 -init ex.sql时,出现错误:
Parse error near line 6: no such column: ostrich
le" , "10" , 4 UNION SELECT "ostrich" , "500"
error here ---^
在我的ex.sql中,只是编码
CREATE TABLE animals AS
SELECT "dog" AS name, "20" AS weight, 4 AS legs UNION
SELECT "cat" , "10" , 4 UNION
SELECT "penguin" , "300" , 2 UNION
SELECT "t-rex" , "12000" , 2 UNION
SELECT "parrot" , "6" , 2 UNION
SELECT "crocodile" , "10" , 4 UNION
SELECT "ostrich" , "500" , 2;
1条答案
按热度按时间lmvvr0a81#
简而言之,
"ostrich"
被认为是列名的标识符。'ostrich'
将被视为预期的文字值。根据:-
字符串常量是通过将字符串括在单引号(')中形成的。字符串中的单引号可以通过将两个单引号放在一行中来编码-就像Pascal中一样。不支持使用反斜杠字符的C样式转义,因为它们不是标准SQL。https://www.sqlite.org/lang_expr.html#literal_values_constants_
更多关于双v单引号的信息请访问:-https://www.sqlite.org/quirks.html#double_quoted_string_literals_are_accepted。
你想要的是用途:-