且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

SQLite3 数据库或磁盘已满/数据库磁盘映像格式错误

更新时间:2022-05-27 22:09:27

需要考虑的几点:

  • SQLite3 DB 文件大致以 DB 页面大小的倍数增长,除非您使用 VACUUM,否则不会缩小.如果删除一些行,释放的空间会在内部标记并在以后的插入中重复使用.因此,插入通常不会导致后备数据库文件的大小发生变化.

  • SQLite3 DB files grow roughly in multiples of the DB page size and do not shrink unless you use VACUUM. If you delete some rows, the freed space is marked internally and reused in later inserts. Therefore an insert will often not cause a change in the size of the backing DB file.

您不应该对 SQLite(或任何其他数据库,就此而言)使用传统的备份工具,因为它们没有考虑数据库状态信息,这对于确保数据库未损坏至关重要.特别是,在插入事务的中间复制数据库文件是灾难的秘诀......

You should not use traditional backup tools for SQLite (or any other database, for that matter), since they do not take into account the DB state information that is critical to ensure an uncorrupted database. Especially, copying the DB files in the middle of an insert transaction is a recipe for disaster...

SQLite3 有一个 API,专门用于备份或复制位于使用.

SQLite3 has an API specifically for backing-up or copying databases that are in use.

是的,您的数据库文件似乎损坏.这可能是硬件/文件系统错误.或者您在使用它们时复制了它们?或者可能恢复了未正确执行的备份?

And yes, it does seem that your DB files are corrupted. It could be a hardware/filesystem error. Or perhaps you copied them while they were in use? Or maybe restored a backup that was not properly taken?