Database / SQLite Interview questions
How do you back up a SQLite database?
Because a SQLite database is just an ordinary file, the simplest backup is a straightforward file copy — but that's only safe when you're certain no write is in progress at the same moment, since copying a file mid-write can capture an inconsistent snapshot.
# simple file copy (only safe if no writes are happening concurrently) cp mydata.db mydata_backup.db # safer: SQLite's built-in backup command, safe even with concurrent activity sqlite3 mydata.db ".backup mydata_backup.db"
The .backup command (or the equivalent sqlite3_backup_* C API) uses SQLite's
dedicated online backup mechanism, which correctly handles a database that's actively being read from or
written to during the backup, producing a consistent snapshot without requiring you to lock out other
activity first — the recommended approach over a raw file copy for any database that might be in active
use.
Invest now in Acorns!!! 🚀
Join Acorns and get your $5 bonus!
Acorns is a micro-investing app that automatically invests your "spare change" from daily purchases into diversified, expert-built portfolios of ETFs. It is designed for beginners, allowing you to start investing with as little as $5. The service automates saving and investing. Disclosure: I may receive a referral bonus.
Invest now!!! Get Free equity stock (US, UK only)!
Use Robinhood app to invest in stocks. It is safe and secure. Use the Referral link to claim your free stock when you sign up!.
The Robinhood app makes it easy to trade stocks, crypto and more.
Webull! Receive free stock by signing up using the link: Webull signup.
More Related questions...
