I'm trying to track down a behavior in SQLite that I don't fully understand
and was hoping to get some help with. Here are three CREATE INDEX
statements for a table called reports that does NOT have a column called
yearz_doesnt_exist:

CREATE INDEX index_reports_on_yearz_doesnt_exist ON reports
(yearz_doesnt_exist);
CREATE INDEX index_reports_on_yearz_doesnt_exist ON reports
('yearz_doesnt_exist');
CREATE INDEX index_reports_on_yearz_doesnt_exist ON reports
("yearz_doesnt_exist");

The first two of these statements will fail with the error 'Error: no such
column: yearz_doesnt_exist', but the last one goes through. After executing
the last statement, if we look at the output of index_list and index_info,
we get:

sqlite> PRAGMA index_list(reports);
0|index_reports_on_yearz_doesnt_exist|0|c|0
sqlite> PRAGMA index_info(index_reports_on_yearz_doesnt_exist);
0|-2|

I understand that the double quotation syntax is used to indicate
identifiers. Functionally, shouldn't it be equivalent to using no quotes in
this example? Why am I allowed to create an index on a non-existent column
when I use double quotes?

(Using SQLite 3.14.0 on macOS 10.12.1.)

Thanks,
Ersin

-- 
Ersin Y. Akinci -- ersinakinci.com
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to