Carradine wrote:
Hello, I am attempting to simply copy a table with data from one database to
abother database with the command:

attach database 'DB.db3' AS V1

CREATE TABLE Table1 AS SELECT * FROM V1.Table1

The creation of the table, and the copying of the data works great. However, my ID field from the original database is an INTEGER PRIMARY KEY,
but when the table gets copied over, it only becomes an INTEGER.

Am I defining my SQL statements wrong?  Or am I going to have to use a
CREATE INDEX call when coying over my table?


Carradine,

The types of the columns in a CREATE ... AS SELECT ... statement are inferred from the result of the SELECT. You will need to create your new table using the same create statement used in the V1 database (i.e. the one with the INTEGER PRIMARY KEY), and then do an INSERT ... SELECT .... instead.

   create table table1 as (....);

   attach database 'DB.db3' as V1;

   begin;
   insert into table1 select * from V1.table1;
   commit;

HTH
Dennis Cote




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

Reply via email to