Hi King, Thank you for the detailed explanation! Now I understand rollback journal a bit more.
John Lin J. King <jk...@jkingweb.ca> 於 2017年11月24日 週五 上午10:28寫道: > The rollback journal is used to return the database to its previous state > in the case of a partial write, not complete writes which are interrupted. > As you didn't commit the transaction, no write occurred, never mind a > partial one, so the database remained in its initial state. > > Deleting a rollback journal is a bad idea. In this case it was harmless, > but normally it's an excellent way to corrupt your database. > > As to where uncommitted transactions live, I am not sure. I'll let someone > else answer that. > > On November 23, 2017 9:13:20 PM EST, "林自均" <johnl...@gmail.com> wrote: > >Hi folks, > > > >When I was learning about rollback journal, I did the following tests: > > > >(in shell 1) > >$ sqlite3 /tmp/db.sqlite > >SQLite version 3.21.0 2017-10-24 18:55:49 > >Enter ".help" for usage hints. > >sqlite> PRAGMA journal_mode; > >delete > >sqlite> CREATE TABLE bank (name STR, money INT); > >sqlite> INSERT INTO bank VALUES ("john", 5566); > >sqlite> BEGIN; > >sqlite> UPDATE bank SET money = money + 100 WHERE name = "john"; > >sqlite> > > > >(then in shell 2) > >$ kill -kill $(pidof sqlite3) # kills the sqlite3 process in shell 1 > >$ rm -f /tmp/db.sqlite-journal > >$ sqlite3 /tmp/db.sqlite .dump > >PRAGMA foreign_keys=OFF; > >BEGIN TRANSACTION; > >CREATE TABLE bank (name STR, money INT); > >INSERT INTO bank VALUES('john',5566); > >COMMIT; > > > >I was expecting that deleting the rollback journal would commit the > >uncommitted transaction (i.e. increase money from 5566 to 5666). > >However, > >it didn't. > > > >I also noticed that the md5sum of db.sqlite are the same before the > >UPDATE > >query and after it, which means that the UPDATE query doesn't really > >write > >into db.sqlite. Does it only write into memory? > > > >Thanks for answering my questions. > > > >John Lin > >_______________________________________________ > >sqlite-users mailing list > >sqlite-users@mailinglists.sqlite.org > >http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users > > -- > Sent from my Android device with K-9 Mail. Please excuse my brevity. > _______________________________________________ > sqlite-users mailing list > sqlite-users@mailinglists.sqlite.org > http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users > _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users