On Wed, Aug 31, 2011 at 10:56:00PM +0100, Tim Streater scratched on the wall:
> In the above, each database is newly created as shown. What I had > forgotten to do was to create the "test" table in the second > database before copying the data. What seems to happen is that, > lacking a "test" table in the test2 database, SQLite appears to > assume that I must mean the "test" table in the test1 database - > it tries to copy data from the table into itself and so gets the > error above. > > Is this reasonable behaviour? I might have expected to have a > "no such table" error. Reasonable or not, it is the defined behavior: http://sqlite.org/lang_attach.html Tables in an attached database can be referred to using the syntax database-name.table-name. If the name of the table is unique across all attached databases and the main and temp databases, then the database-name prefix is not required. If two or more tables in different databases have the same name and the database-name prefix is not used on a table reference, then the table chosen is the one in the database that was least recently attached. In other words, SQLite will generally search the temp database, the main database, and then all attached databases in index order. This brings up some odd edge cases, as the temp database is searched before the main database, even though the main database has a lower index, but it generally works as expected. -j -- Jay A. Kreibich < J A Y @ K R E I B I.C H > "Intelligence is like underwear: it is important that you have it, but showing it to the wrong people has the tendency to make them feel uncomfortable." -- Angela Johnson _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users