Today when trying to copy from one database to another, I had the following 
error (simplified example below):

  Second-Mini% sqlite3 test1
  sqlite> create table test (absid integer primary key, otherfield integer);
  sqlite> insert into test (absid,otherfield) values (null, 10);
  sqlite> insert into test (absid,otherfield) values (null, 20);
  sqlite> select * from test;
  absid     | otherfield
  ----------+-----------
  1         | 10        
  2         | 20        
  sqlite> ^D

  Second-Mini% sqlite3 test2
  sqlite> attach database test1 as src;
  sqlite> insert into test select * from src.test;
  Error: PRIMARY KEY must be unique
  sqlite> 

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.

--
Cheers  --  Tim
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to