SQLITE3 VACUUM, “database or disk is full”

后端 未结 3 1556
甜味超标
甜味超标 2020-11-30 12:23

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 d         


        
相关标签:
3条回答
  • 2020-11-30 12:49

    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
    0 讨论(0)
  • 2020-11-30 12:54

    Probably the drive, where your temporary files are created, has not enough space. See here Vacuum-command-is-failing-with-SQL-Error-Database-or-disk-is-full

    0 讨论(0)
  • 2020-11-30 13:02

    The OP noted that during a VACUUM, SQLite creates a temporary file that is approximately the same size as the original database. It does this in order to maintain the database ACID properties. SQLite uses a directory to hold the temporary files it needs while doing the VACUUM. In order to determine what directory to use, it descends a hierarchy looking for the first directory that has the proper access permissions. If it finds a directory that it doesn't have access to, it will ignore that directory and continue to descend the hierarchy looking for one that it does. I mention this in case anyone has specified an environment variable and SQLite seems to be ignoring it.

    In his answer CL gives the hierarchy for Linux and in his comment mentions that the hierarchy is OS-dependent. For completeness, here is the hierarchies (in so far as I can determine them from the code).

    For Unix (and Linux) the hierarchy is:

    1. Whatever is specified by the SQLITE_TMPDIR environment variable,
    2. Whatever is specified by the TMPDIR environment variable,
    3. /var/tmp,
    4. /usr/tmp,
    5. /tmp, and finally
    6. The current working directory.

    For Cygwin the hierarchy is:

    1. Whatever is specified by the SQLITE_TMPDIR environment variable,
    2. Whatever is specified by the TMPDIR environment variable,
    3. Whatever is specified by the TMP environment variable,
    4. Whatever is specified by the TEMP environment variable,
    5. Whatever is specified by the USERPROFILE environment variable,
    6. /var/tmp,
    7. /usr/tmp,
    8. /tmp, and finally
    9. The current working directory.

    For Windows the hierarchy is:

    • GetTempPath(), which is documented to return:

      1. Whatever is specified by the TMP environment variable,
      2. Whatever is specified by the TEMP environment variable,
      3. Whatever is specified by the USERPROFILE environment variable, and finally
      4. the Windows directory.

    Hope this helps.

    0 讨论(0)
提交回复
热议问题