Domanda

I have one database with one table and another database. I need to copy this one table from the first database (with simple table) to the second. (In second database it should be fts3 table). So, I can open both databases, create new fts3 in the second db and copy all data from the first to the second via select -> insert queries. But is there any other ways to do it faster and better?

È stato utile?

Soluzione

As far as I know the methodology you described (i.e. INSERT INTO db2.tbl SELECT * FROM db1.tbl) should generally be the most efficient.

What you can do is tweak sqlite to do it faster. The first thing that comes to mind is to disable journaling (normally dangerous, but should be acceptable in your scenario as you still have an original of the data):

pragma PRAGMA journal_mode=OFF:

You can also turn off the synchronous pragma (also dangerous):

PRAGMA synchronous=OFF;

There are one or two more pragmas you can play with that could make a difference, but I think the two I mention will have the biggest impact.

Be sure to restore those pragmas to their original values after the copy.

Altri suggerimenti

Well yes, that is the best way. Create table and then insert the data:

INSERT INTO `toDB`.`tableName` SELECT * FROM `fromDB`.`tableName` 
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top