2016-03-25 66 views
0

我在sqlite3的數據庫中的表徑(即處理自行車道,其模式是:Sqlit3不接受空格中輸入

CREATE TABLE trails (ID integer primary key, name text, city text, state char(2), length integer, ascent integer, difficulty char(2), description text); 

然後我嘗試插入值是:

INSERT INTO trails (name, city, state, length, ascent, difficulty, description) VALUES (‘Blue'Sky’,‘Fort Collins’,‘CO’, 6, 300, ‘bg’, ‘cool trail’); 

我認爲,數據類型的文本將採取給予任何形式的字符串(甚至那些字符串,例如一個段落)。這是怎麼回事了?

+1

您正在使用非ASCII引用字符(''''),該SQLite可能不會解析。 –

回答

1

字符串的字符可以是單引號'或雙引號"。當字符串包含單引號時使用雙引號。

CREATE TABLE trails (ID integer primary key, name text, city text, state char(2), length integer, ascent integer, difficulty char(2), description text); 

INSERT INTO trails (name, city, state, length, ascent, difficulty, description) VALUES ("Blue'Sky","Fort Collins","CO", 6, 300, "bg", "cool trail"); 
+1

啊,謝謝。另外,我在Google Docs中撰寫查詢,並複製並粘貼到終端中。任何遇到此問題的人都應該謹慎:在文本編輯器中編寫您的查詢! –