SQLITE3 VACUUM, “database or disk is full”

后端 未结 3 1558
甜味超标
甜味超标 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 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.

提交回复
热议问题