Perché SQLite non mi consente di interrogare un database allegato specifico?

Perché SQLite non mi consente di interrogare un database allegato specifico?


SQLite version 3.7.3
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> ATTACH DATABASE 'test.db' AS 12;
sqlite> SELECT * FROM ids;
1|hi
2|hilo
3|hiloa
4|hiloas
sqlite> .databases
seq name file
--- --------------- ----------------------------------------------------------
0 main
2 12 C:\test.db
sqlite> SELECT * FROM 12.ids;
Error: unrecognized token: "12.ids"

Perché sbaglia? I dati sono chiaramente lì.


Risposte:


SELECT * FROM `12`.ids;

Se hai intenzione di utilizzare nomi dispari (come quelli tutti numerici), faresti meglio a evitarli correttamente.


Alcune risposte al codice


SQLite version 3.7.3 Enter ".help" for instructions Enter SQL statements terminated with a ";" sqlite>
ATTACH DATABASE 'test.db' AS 12;
sqlite>
SELECT * FROM ids;
1|hi 2|hilo 3|hiloa 4|hiloas sqlite>
.databases seq name file --- --------------- ---------------------------------------------------------- 0 main 2 12 C:\test.db sqlite>
SELECT * FROM 12.ids;
Error: unrecognized token: "12.ids"
SELECT * FROM `12`.ids;