combine multiple sqlite databases with same structure

The only way that this would work is if the primary key is defined as INTEGER PRIMARY KEY and there is no need to create and update a temporary table.

After you attach db2 execute this statement:

INSERT INTO mytable(col1, col2, ....) 
SELECT col1, col2, .... 
FROM db2.mytable;

By enumerating all the columns except the primary key you will insert all the rows of db2.mytable in mytable and a new value will be assigned to their primary key column.

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top