Copying data between tables in SQLite3
Let's say I am copying data between tables like this:
insert into table2 (name, address)
select name, address
from table1
Will this execute in a single transaction?
ie. I would like one thread to copy the data from table1 开发者_如何学JAVAto table2, and another thread that would make select
queries on the data in table2 WHILE they're copied. Is that possible?
I am using SQLite 3.7.
That query would be all one transaction. If you need the copied rows returned, it's going to be either before or after they are copied, not while. Meaning that you could begin a transaction manually, do a select on table 1, then do your insert (or the other way) and finally commit. Getting it on different threads means possibly having a different set of inserts versus select while you do each, if something was inserted in the interim (slim chance in many contexts, but can happen).
精彩评论