Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQLITE3 VACUUM, "database or disk is full"

Tags:

I'm trying to run the VACUUM command on my database, but I seem to run out of space:

> sqlite3 mydatabase.db "VACUUM" Error: database or disk is full 

The database is about 36 GB and the drive that I'm running it on looks like (via df -h):

Filesystem      Size  Used Avail Use% Mounted on /dev/sda2       406G  171G  215G  45% /home 

So I am clearly above the double size limited needed. What can I do to allow the vacuum command to run?

like image 771
Hooked Avatar asked Apr 23 '14 16:04

Hooked


People also ask

What does VACUUM do in SQLite?

VACUUM command cleans the main database by copying its contents to a temporary database file and reloading the original database file from the copy. This eliminates free pages, aligns table data to be contiguous, and otherwise cleans up the database file structure.

How do I fix SQLite database disk image is malformed?

If you find the 'SQLite Database Disk Image is malformed' error, export your database into an SQL file. To export the data, click the File tab followed by Export>>Database to SQL file. The Export SQL dialog box appears on the screen; select the objects you want to export and define the other options.

How much data can sqlite3 hold?

SQLite database files have a maximum size of about 140 TB. On a phone, the size of the storage (a few GB) will limit your database file size, while the memory size will limit how much data you can retrieve from a query. Furthermore, Android cursors have a limit of 1 MB for the results.

How do I fix database disk image is malformed?

You may see the "database disk image is malformed" error in TekRADIUS log. This could happen during unplanned shutdown or reboot. The error indicates that one or more of the sqlite3 databases may have become corrupted. You need to have sqlite3.exe to diagnose and fix the problem.


1 Answers

To allow the VACUUM command to run, change the directory for temporary files to one that has enough free space.

SQLite's documentation says the temporary directory is (in order):

  1. whatever is set with the PRAGMA temp_store_directory command; or
  2. whatever is set with the SQLITE_TMPDIR environment variable; or
  3. whatever is set with the TMPDIR environment variable; or
  4. /var/tmp; or
  5. /usr/tmp; or
  6. /tmp; or
  7. ., the current working directory
like image 114
CL. Avatar answered Oct 07 '22 20:10

CL.