Wenton Thomas wrote: > What's the execution sequence about " insert ino A select .... from B "? > I means,which is correct prescription in the following: > (1) select all rows from B at first, then insert all the result into > table A; > (2) select a row from B ,then insert the row into table A immediately, repeat > the precess. > > When in doubt ask sqlite. :-)
SQLite version 3.6.14 Enter ".help" for instructions Enter SQL statements terminated with a ";" sqlite> .explain on sqlite> create table t1(a,b); sqlite> create table t2(c,d); sqlite> explain insert into t2 select * from t1; addr opcode p1 p2 p3 p4 p5 comment ---- ------------- ---- ---- ---- ------------- -- ------------- 0 Trace 0 0 0 00 1 Goto 0 13 0 00 2 Noop 0 0 0 00 3 OpenWrite 1 3 0 2 00 4 OpenRead 0 2 0 2 00 5 Rewind 0 10 0 00 6 NewRowid 1 2 0 00 7 RowData 0 1 0 00 8 Insert 1 1 2 t2 0b 9 Next 0 6 0 00 10 Close 0 0 0 00 11 Close 1 0 0 00 12 Halt 0 0 0 00 13 Transaction 0 1 0 00 14 VerifyCookie 0 2 0 00 15 TableLock 0 3 1 t2 00 16 TableLock 0 2 0 t1 00 17 Goto 0 2 0 00 sqlite> From this it's easy (relatively) to see that inserts each row as it find them while executing the select. HTH Dennis Cote _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users