1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
- <html><head>
- <title>SQLite Query Language: VACUUM</title>
- <style type="text/css">
- body {
- margin: auto;
- font-family: Verdana, sans-serif;
- padding: 8px 1%;
- }
- a { color: #45735f }
- a:visited { color: #734559 }
- .logo { position:absolute; margin:3px; }
- .tagline {
- float:right;
- text-align:right;
- font-style:italic;
- width:240px;
- margin:12px;
- margin-top:58px;
- }
- .toolbar {
- font-variant: small-caps;
- text-align: center;
- line-height: 1.6em;
- margin: 0;
- padding:1px 8px;
- }
- .toolbar a { color: white; text-decoration: none; padding: 6px 12px; }
- .toolbar a:visited { color: white; }
- .toolbar a:hover { color: #80a796; background: white; }
- .content { margin: 5%; }
- .content dt { font-weight:bold; }
- .content dd { margin-bottom: 25px; margin-left:20%; }
- .content ul { padding:0px; padding-left: 15px; margin:0px; }
- /* rounded corners */
- .se { background: url(images/se.png) 100% 100% no-repeat #80a796}
- .sw { background: url(images/sw.png) 0% 100% no-repeat }
- .ne { background: url(images/ne.png) 100% 0% no-repeat }
- .nw { background: url(images/nw.png) 0% 0% no-repeat }
- </style>
- <meta http-equiv="content-type" content="text/html; charset=UTF-8">
-
- </head>
- <body>
- <div><!-- container div to satisfy validator -->
- <a href="lang.html">
- <h2 align="center">SQL As Understood By SQLite</h2></a><h1>VACUUM</h1><h4><a href="syntaxdiagrams.html#vacuum-stmt">vacuum-stmt:</a></h4><blockquote> <img alt="syntax diagram vacuum-stmt" src="images/syntax/vacuum-stmt.gif"></img> </blockquote>
- <p>When an object (table, index, or trigger) is dropped from the
- database, it leaves behind empty space.
- This empty space will be reused the next time new information is
- added to the database. But in the meantime, the database file might
- be larger than strictly necessary. Also, frequent inserts, updates,
- and deletes can cause the information in the database to become
- fragmented - scrattered out all across the database file rather
- than clustered together in one place.</p>
- <p>The 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.</p>
- <p>The VACUUM command may change the
- <a href="lang_createtable.html#rowid">ROWIDs</a> of entries in tables that do
- not have an explicit <a href="lang_createtable.html#rowid">INTEGER PRIMARY KEY</a>.</p>
- <p>VACUUM only works on the main database.
- It is not possible to VACUUM an attached database file.</p>
- <p>The VACUUM command will fail if there is an active transaction.
- The VACUUM command is a no-op for in-memory databases.</p>
- <p>As of SQLite version 3.1, an alternative to using the VACUUM command
- is auto-vacuum mode, enabled using the
- <a href="pragma.html#pragma_auto_vacuum">auto_vacuum</a> pragma. When <a href="pragma.html#pragma_auto_vacuum">auto_vacuum</a> is enabled for a database,
- large deletes cause
- the size of the database file to shrink. However, <a href="pragma.html#pragma_auto_vacuum">auto_vacuum</a>
- also causes excess fragmentation of the database file. And <a href="pragma.html#pragma_auto_vacuum">auto_vacuum</a>
- does not compact partially filled pages of the database as VACUUM
- does.</p>
- <p>The <a href="pragma.html#pragma_page_size">page_size</a> and/or <a href="pragma.html#pragma_auto_vacuum">auto_vacuum</a> mode of a database can be changed
- by invoking the <a href="pragma.html#pragma_page_size">page_size pragma</a> and/or <a href="pragma.html#pragma_auto_vacuum">auto_vacuum pragma</a> and then
- immediately VACUUMing the database.</p>
|