Luca Moratto wrote:
Hi,

I'm using c++ interface for SQLite 3.3.8.

1) I open a db in memory,
2) attach a file with one table with a INTEGER PRIMARY KEY (ATTACH DATABASE 'SQliteFile.s3db' AS 'attachedDb'), 3) copy in memory the tble from attached db table (CREATE TABLE 'myTable' AS SELECT * FROM 'attachedDb.myTable')

I don't think this is your problem, but the docs say:

You cannot create a new table with the same name as a table in an attached database....

It would seem that perhaps this restriction has been removed (or does not apply to :memory: databases).

But, the CREATE TABLE AS command does not do everything you (or I) would wish:

$ sqlite3 test.sq3
SQLite version 3.3.13
Enter ".help" for instructions
sqlite> create table mytable(a integer primary key);
sqlite> insert into mytable values('1');
sqlite> insert into mytable values('2');
sqlite> select * from mytable;
1
2
sqlite> .exit

Gerald [EMAIL PROTECTED] ~
$ sqlite3 :memory:
SQLite version 3.3.13
Enter ".help" for instructions
sqlite> attach "test.sq3" as attached;
sqlite> create table mynewtable as select * from attached.mytable;
sqlite> select sql from sqlite_main;
SQL error: no such table: sqlite_main
sqlite> select sql from sqlite_master;
CREATE TABLE mynewtable(a integer)
sqlite> select sql from attached.sqlite_master;
CREATE TABLE mytable(a integer primary key)

The "primary key" part of the field definition gets dropped. And therefore the table does not behave as you expect. You need to create the :memory: table differently.

HTH,

Gerry

-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------

Reply via email to