SQLite: The easiest way to copy a table from one database to another?

I have two sqlite databases and you want to copy a table from database A to database B. Other tables in database A should not be copied. What is the easiest way to do this in Java?

I could finally do something like Select * from A and then paste it all into Base B, but shouldn't there be a better way?

+6
source share
1 answer

Open the database from which you are copying, then run this code to attach the database to which you are copying and then copy the table.

ATTACH DATABASE 'other.db' AS other; INSERT INTO other.tbl SELECT * FROM main.tbl; 
+11
source

Source: https://habr.com/ru/post/984157/


All Articles