4 ms·
TL;DR All replacements for fopen() grow until they span multiple files.
by ArbitraryLimits 14y ago
TL;DR All replacements for fopen() grow until they span multiple files.
- dchest 14y agoWhy multiple files? The (default) on-disk database image is a single disk file with a well-documented and stable file format, making the SQLite4 library suitable for use as an application file format.
- rogerbinns 14y agoIncidentally SQLite isn't actually a single file. The main database is. Transactions in progress and the WAL are stored in other files. If you copied just the main file at an inopportune time then it would be invalid. You have to keep the main file and the journal/WAL together.
- dchest 14y agoJournal is a temporary file created when writing into database, which you can turn off. http://www.sqlite.org/pragma.html#pragma_journal_mode http://www.sqlite.org/pragma.html#pragma_journal_mode WAL mode is a different beast specifically not intended to be a replacement for application format database, and it's not used by default. So, no, SQLite is a single-file database. It provides more options than that, but the statement is true.
- rogerbinns 14y agoYou can't turn off the journal unless you are happy to lose data in which case don't bother with a database. See section 1.3 of http://www.sqlite.org/howtocorrupt.html http://www.sqlite.org/howtocorrupt.html
- dchest 14y agoThere are many more reasons to use single-file databases other than safety of file write operations. TextEdit in OS X also creates a temporary file when it saves a document, and then atomically renames it to the original filename; would you claim that RTF document consists of two files in this case?
- rogerbinns 14y agoNot even a close analogy as the text file is always valid. More accurate would be changes being done by modifying blocks of the original file as well as appends on the end so that it is not valid by itself, and storing enough information to make it valid/undo in a second file.