Tim Streater wrote:
> I have a handy SELECT available, but I don't want to actually insert
> a row at that time. Testing with the shell, the following appears to
> work:
>
>   attach database ':memory:' as mem;
>   create table mem.messages as select * from main.messages limit 0;
>
> and I get a new, empty, table with the same columns. Is this supposed
> to work in this way?

The documentation says:
| The table has the same number of columns as the rows returned by the
| SELECT statement.

This is indeed misleading.  The result set actually has columns and
column names even when there are now rows in it, so this is guaranteed
to work even for empty result sets.  (The sqlite3 shell avoids
displaying column names for empty result sets on purpose, whatever that
purpose might be.)


Regards,
Clemens
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to