Igor is naturally correct. One additional thing to keep in mind - the commit phase of a transaction is where a lot of work gets done (meaning slow disk access). So if you have a lot of INSERTs or DELETEs to do, doing many within a transaction will give you better performance.
Doug -----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of Igor Tandetnik Sent: Wednesday, August 28, 2013 5:44 PM To: [email protected] Subject: Re: [sqlite] To BEGIN or not to BEGIN. That is the question... On 8/28/2013 6:28 PM, jose isaias cabrera wrote: > I know that if I am doing INSERTs and such, I need to, > > BEGIN; > INSERT... > END; No, you don't need to. You can, if you want to, but there's no reason to have to. > But, do I need to begin if I am going to create a table? ie. > > BEGIN; > CREATE TABLE tableName > ( > JobID integer primary key, SubProjID integer, ProjID integer > ); > END; Same here. > Also, what other commands should I wrap with BEGINs and ENDs? BEGIN starts an explicit transaction; END commits the same. You need an explicit transaction if you want to execute two or more statements atomically, so that either they all succeed, or one fails and then the database is rolled back to the original state. If you don't start a transaction explicitly, then each statement is implicitly wrapped in its own transaction. -- Igor Tandetnik _______________________________________________ sqlite-users mailing list [email protected] http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users _______________________________________________ sqlite-users mailing list [email protected] http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

