doc-exports/docs/dws/dev/dws_06_0226.html
Lu, Huayi e6fa411af0 DWS DEV 830.201 version
Reviewed-by: Pruthi, Vineet <vineet.pruthi@t-systems.com>
Co-authored-by: Lu, Huayi <luhuayi@huawei.com>
Co-committed-by: Lu, Huayi <luhuayi@huawei.com>
2024-05-16 07:24:04 +00:00

127 lines
31 KiB
HTML

<a name="EN-US_TOPIC_0000001188110586"></a><a name="EN-US_TOPIC_0000001188110586"></a>
<h1 class="topictitle1">VACUUM</h1>
<div id="body8662426"><div class="section" id="EN-US_TOPIC_0000001188110586__s5f7bdd0d4677446eaa64ae35d4e4368e"><h4 class="sectiontitle">Function</h4><p id="EN-US_TOPIC_0000001188110586__a780d55c706514bef9dbf326f1f30a4d4"><strong id="EN-US_TOPIC_0000001188110586__b19257182614402">VACUUM</strong> reclaims storage space occupied by tables or B-tree indexes. In normal database operation, rows that have been deleted are not physically removed from their table; they remain present until a <strong id="EN-US_TOPIC_0000001188110586__b1738963220409">VACUUM</strong> is done. Therefore, it is necessary to execute <strong id="EN-US_TOPIC_0000001188110586__b56508115015">VACUUM</strong> periodically, especially on frequently-updated tables.</p>
<p id="EN-US_TOPIC_0000001188110586__a179e79d60dad4271ba132f8b142a71a1"></p>
</div>
<div class="section" id="EN-US_TOPIC_0000001188110586__s7e5c0f0dc67f4d92bd42a90da65bdd56"><h4 class="sectiontitle">Precautions</h4><ul id="EN-US_TOPIC_0000001188110586__u216339b873a44c2696c2ba1bc1de4585"><li id="EN-US_TOPIC_0000001188110586__li139421524202111">With no table specified, <strong id="EN-US_TOPIC_0000001188110586__b65171128220">VACUUM</strong> processes all the tables that the current user has permission to vacuum in the current database. With a table specified, <strong id="EN-US_TOPIC_0000001188110586__b1337720401027">VACUUM</strong> processes only that table.</li><li id="EN-US_TOPIC_0000001188110586__li295951551618">To perform <strong id="EN-US_TOPIC_0000001188110586__b124501498394">VACUUM</strong> on a table, you must be the owner of the table, granted with the <strong id="EN-US_TOPIC_0000001188110586__b158041743184016">VACUUM</strong> permission on the table, or granted with the <strong id="EN-US_TOPIC_0000001188110586__b202980020413">gs_role_vacuum_any</strong> role. By default, a system administrator has this permission. However, database owners are allowed to <strong id="EN-US_TOPIC_0000001188110586__b1698112817398">VACUUM</strong> all tables in their databases, except shared catalogs. (The restriction for shared catalogs means that a true database-wide <strong id="EN-US_TOPIC_0000001188110586__b39915286398">VACUUM</strong> can only be executed by the system administrator). <strong id="EN-US_TOPIC_0000001188110586__b1236468015442">VACUUM</strong> skips over any tables that the calling user does not have the permission to vacuum.</li><li id="EN-US_TOPIC_0000001188110586__l9e21b7f61c554ad0b4973f9586fb6c02"><strong id="EN-US_TOPIC_0000001188110586__b4417326015442">VACUUM</strong> cannot be executed inside a transaction block.</li><li id="EN-US_TOPIC_0000001188110586__l383522e91af241e681662fecd8c60100">It is recommended that active production databases be vacuumed frequently (at least nightly), in order to remove dead rows. After adding or deleting a large number of rows, it might be a good idea to execute the <strong id="EN-US_TOPIC_0000001188110586__b6201502015442">VACUUM ANALYZE</strong> command for the affected table. This will update the system catalogs with the results of all recent changes, and allow the query planner to make better choices in planning queries.</li><li id="EN-US_TOPIC_0000001188110586__l2bab399527cd4b2fa97a2da4da801b80"><strong id="EN-US_TOPIC_0000001188110586__b50637766161821">FULL</strong> is recommended only in special scenarios. For example, you wish to physically narrow the table to decrease the occupied disk space after deleting most rows of a table. <strong id="EN-US_TOPIC_0000001188110586__b187018472162">VACUUM FULL</strong> usually shrinks more table size than <strong id="EN-US_TOPIC_0000001188110586__b15701134713161">VACUUM</strong>. If the physical space usage does not decrease after you run the command, check whether there are other active transactions (that have started before you delete data transactions and not ended before you run <strong id="EN-US_TOPIC_0000001188110586__b151151211151120">VACUUM FULL</strong>). If there are such transactions, run this command again when the transactions quit.</li><li id="EN-US_TOPIC_0000001188110586__l0a6727aa520e416082e887b896e61a99"><strong id="EN-US_TOPIC_0000001188110586__b6661830315442">VACUUM</strong> causes a substantial increase in I/O traffic, which might cause poor performance for other active sessions. Therefore, it is sometimes advisable to use the cost-based VACUUM delay feature.</li><li id="EN-US_TOPIC_0000001188110586__l9bade9059c964dd88290ec76ff1149e5">When <strong id="EN-US_TOPIC_0000001188110586__b6269381615442">VERBOSE</strong> is specified, <strong id="EN-US_TOPIC_0000001188110586__b2737343715442">VACUUM</strong> prints progress messages to indicate which table is currently being processed. Various statistics about the tables are printed as well. </li><li id="EN-US_TOPIC_0000001188110586__l0995fb8a8957452e9dd55c61e76e6780">When the option list is surrounded by parentheses, the options can be written in any order. If there are no brackets, the options must be given in the order displayed in the syntax.</li><li id="EN-US_TOPIC_0000001188110586__li17588174212372"><strong id="EN-US_TOPIC_0000001188110586__b842352706135448">VACUUM</strong> and <strong id="EN-US_TOPIC_0000001188110586__b842352706135451">VACUUM FULL</strong> clear deleted tuples after the delay specified by <strong id="EN-US_TOPIC_0000001188110586__b84235270613553">vacuum_defer_cleanup_age</strong>.</li><li id="EN-US_TOPIC_0000001188110586__li18270174310219"><strong id="EN-US_TOPIC_0000001188110586__b55386423413">VACUUM ANALYZE</strong> executes a VACUUM operation and then an ANALYZE operation for each selected table. This is a handy combination form for routine maintenance scripts.</li><li id="EN-US_TOPIC_0000001188110586__li879952162614">Plain <strong id="EN-US_TOPIC_0000001188110586__b3428328815015">VACUUM</strong> (without <strong id="EN-US_TOPIC_0000001188110586__b4011414415015">FULL</strong>) recycles space and makes it available for reuse. This form of the command can operate in parallel with normal reading and writing of the table, as an exclusive lock is not obtained. <strong id="EN-US_TOPIC_0000001188110586__b2548298015015">VACUUM FULL</strong> executes wider processing, including moving rows across blocks to compress tables so they occupy minimum number of disk blocks. This form is much slower and requires an exclusive lock on each table while it is being processed.</li><li id="EN-US_TOPIC_0000001188110586__li125798507388">When you do <strong id="EN-US_TOPIC_0000001188110586__b611412168320">VACUUM</strong> to a column-store table, the following operations are internally performed: data in the delta table is migrated to the primary table, and the delta and desc tables of the primary table are vacuumed. <strong id="EN-US_TOPIC_0000001188110586__b9269818183212">VACUUM</strong> does not reclaim the storage space of the delta table. To reclaim it, do <strong id="EN-US_TOPIC_0000001188110586__b14269618103217">VACUUM DELTAMERGE</strong> to the column-store table.</li><li id="EN-US_TOPIC_0000001188110586__li1039564945512">If you perform VACUUM FULL when a long-running query accesses a system table, the long-running query may prevent VACUUM FULL from accessing the system table. As a result, the connection times out and an error is reported.</li><li id="EN-US_TOPIC_0000001188110586__li1116911718409">Running <strong id="EN-US_TOPIC_0000001188110586__b344314214019">VACUUM FULL</strong> on a column-store partitioned table locks the table and its partitions.</li><li id="EN-US_TOPIC_0000001188110586__li984155351813">Concurrent VACUUM FULL operations on system catalogs may cause local deadlocks.</li><li id="EN-US_TOPIC_0000001188110586__li1246245516214">When a <strong id="EN-US_TOPIC_0000001188110586__b18440164215120">VACUUM FULL</strong> operation is performed on a table, it triggers table rebuilding. During this rebuilding process, data is dumped into a new data file. Once the rebuilding is complete, the original file is deleted. However, it is important to note that if the table is large, the rebuilding process can consume a significant amount of disk space. When the disk space is insufficient, exercise caution when performing the <strong id="EN-US_TOPIC_0000001188110586__b1241135435118">VACUUM FULL</strong> operation on large tables to prevent the cluster from being read-only.</li></ul>
</div>
<div class="section" id="EN-US_TOPIC_0000001188110586__s4b75675b19e94f2495504d35844b9d8c"><h4 class="sectiontitle">Syntax</h4><ul id="EN-US_TOPIC_0000001188110586__u39b8a29fed5d4a5395afcc9a26478535"><li id="EN-US_TOPIC_0000001188110586__l88ef7230373c4283bf45744079953ecc">Reclaim space and update statistics. The keyword sequence must be given in the order in which the syntax is displayed.<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001188110586__sd21f5016f55343f2836d700533a9cd51"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span>
<span class="normal">2</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">VACUUM</span><span class="w"> </span><span class="p">[</span><span class="w"> </span><span class="p">(</span><span class="w"> </span><span class="err">{</span><span class="w"> </span><span class="k">FULL</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="k">FREEZE</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="k">VERBOSE</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="err">{</span><span class="k">ANALYZE</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="k">ANALYSE</span><span class="w"> </span><span class="err">}}</span><span class="w"> </span><span class="p">[,...]</span><span class="w"> </span><span class="p">)</span><span class="w"> </span><span class="p">]</span>
<span class="w"> </span><span class="p">[</span><span class="w"> </span><span class="k">table_name</span><span class="w"> </span><span class="p">[</span><span class="w"> </span><span class="p">(</span><span class="k">column_name</span><span class="w"> </span><span class="p">[,</span><span class="w"> </span><span class="p">...]</span><span class="w"> </span><span class="p">)</span><span class="w"> </span><span class="p">]</span><span class="w"> </span><span class="p">]</span><span class="w"> </span><span class="p">[</span><span class="w"> </span><span class="n">PARTITION</span><span class="w"> </span><span class="p">(</span><span class="w"> </span><span class="n">partition_name</span><span class="w"> </span><span class="p">)</span><span class="w"> </span><span class="p">];</span>
</pre></div></td></tr></table></div>
</div>
</li><li id="EN-US_TOPIC_0000001188110586__l7ebe0c5a127344028b6dedb72126858b">Reclaim space, without updating statistics information.<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001188110586__s3c5480df05c34bbdb1549263d1b502d5"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">VACUUM</span><span class="w"> </span><span class="p">[</span><span class="w"> </span><span class="k">FULL</span><span class="w"> </span><span class="p">[</span><span class="n">COMPACT</span><span class="p">]</span><span class="w"> </span><span class="p">]</span><span class="w"> </span><span class="p">[</span><span class="w"> </span><span class="k">FREEZE</span><span class="w"> </span><span class="p">]</span><span class="w"> </span><span class="p">[</span><span class="w"> </span><span class="k">VERBOSE</span><span class="w"> </span><span class="p">]</span><span class="w"> </span><span class="p">[</span><span class="w"> </span><span class="k">table_name</span><span class="w"> </span><span class="p">]</span><span class="w"> </span><span class="p">[</span><span class="w"> </span><span class="n">PARTITION</span><span class="w"> </span><span class="p">(</span><span class="w"> </span><span class="n">partition_name</span><span class="w"> </span><span class="p">)</span><span class="w"> </span><span class="p">];</span>
</pre></div></td></tr></table></div>
</div>
</li><li id="EN-US_TOPIC_0000001188110586__l4ea7e71c9b174f669a3b044b14d48a14">Reclaim space and update statistics information, with a specific order of keywords required.<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001188110586__s9ca41f0090ba42d0b8d94e564ecdab1c"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span>
<span class="normal">2</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">VACUUM</span><span class="w"> </span><span class="p">[</span><span class="w"> </span><span class="k">FULL</span><span class="w"> </span><span class="p">]</span><span class="w"> </span><span class="p">[</span><span class="w"> </span><span class="k">FREEZE</span><span class="w"> </span><span class="p">]</span><span class="w"> </span><span class="p">[</span><span class="w"> </span><span class="k">VERBOSE</span><span class="w"> </span><span class="p">]</span><span class="w"> </span><span class="err">{</span><span class="w"> </span><span class="k">ANALYZE</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="k">ANALYSE</span><span class="w"> </span><span class="err">}</span><span class="w"> </span><span class="p">[</span><span class="w"> </span><span class="k">VERBOSE</span><span class="w"> </span><span class="p">]</span><span class="w"> </span>
<span class="w"> </span><span class="p">[</span><span class="w"> </span><span class="k">table_name</span><span class="w"> </span><span class="p">[</span><span class="w"> </span><span class="p">(</span><span class="k">column_name</span><span class="w"> </span><span class="p">[,</span><span class="w"> </span><span class="p">...]</span><span class="w"> </span><span class="p">)</span><span class="w"> </span><span class="p">]</span><span class="w"> </span><span class="p">]</span><span class="w"> </span><span class="p">[</span><span class="w"> </span><span class="n">PARTITION</span><span class="w"> </span><span class="p">(</span><span class="w"> </span><span class="n">partition_name</span><span class="w"> </span><span class="p">)</span><span class="w"> </span><span class="p">];</span>
</pre></div></td></tr></table></div>
</div>
</li><li id="EN-US_TOPIC_0000001188110586__l3116df7d0a5348c3b9a0458b427d82fb">For HDFS tables, migrate data from the delta table to the primary table.<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001188110586__s254c3369a8824ff9956f4c2beb7d0cdf"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">VACUUM</span><span class="w"> </span><span class="n">DELTAMERGE</span><span class="w"> </span><span class="p">[</span><span class="w"> </span><span class="k">table_name</span><span class="w"> </span><span class="p">];</span>
</pre></div></td></tr></table></div>
</div>
</li><li id="EN-US_TOPIC_0000001188110586__l5340ea229cd2495a8dd7c0e38b978bdf">For HDFS tables, delete the empty value partition directory of HDFS table in HDFS storage.<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001188110586__screen624410348416"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">VACUUM</span><span class="w"> </span><span class="n">HDFSDIRECTORY</span><span class="w"> </span><span class="p">[</span><span class="w"> </span><span class="k">table_name</span><span class="w"> </span><span class="p">];</span>
</pre></div></td></tr></table></div>
</div>
</li></ul>
</div>
<div class="section" id="EN-US_TOPIC_0000001188110586__se83e416dc0b242ca98b7568cca0d3721"><h4 class="sectiontitle">Parameter Description</h4><ul id="EN-US_TOPIC_0000001188110586__uf0e23e064b1f4a23a7c36f51b83c6d9a"><li id="EN-US_TOPIC_0000001188110586__l524bf909d24d42a0889f9f4210f5c660"><strong id="EN-US_TOPIC_0000001188110586__a1bccac88dcf445c295e876f24440c9bd">FULL</strong><p id="EN-US_TOPIC_0000001188110586__a5bec58eb5e1248548f092ba85ca2f9f4">Selects "FULL" vacuum, which can reclaim more space, but takes much longer and exclusively locks the table.</p>
<p id="EN-US_TOPIC_0000001188110586__aa42be404223a48a49d7f76d2daaf1e08"><strong id="EN-US_TOPIC_0000001188110586__b842352706164957">FULL</strong> options can also contain the <strong id="EN-US_TOPIC_0000001188110586__b842352706165018">COMPACT</strong> parameter, which is only used for the HDFS table. Specifying the <strong id="EN-US_TOPIC_0000001188110586__b892175117112335">COMPACT</strong> parameter improves <strong id="EN-US_TOPIC_0000001188110586__b514019716112319">VACUUM FULL</strong> operation performance.</p>
<p id="EN-US_TOPIC_0000001188110586__ac90ba3677dbf483b9e3b40bbd9f54917"><strong id="EN-US_TOPIC_0000001188110586__b842352706165341">COMPACT</strong> and <strong id="EN-US_TOPIC_0000001188110586__b842352706165344">PARTITION</strong> cannot be used at the same time.</p>
<div class="note" id="EN-US_TOPIC_0000001188110586__n57895ae63892457d800aea87a40bf72d"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="EN-US_TOPIC_0000001188110586__a133139aecff44a10b80c73391a72e3b5">Using <strong id="EN-US_TOPIC_0000001188110586__b18651614151617">FULL</strong> will cause statistics missing. To collect statistics, add the keyword <strong id="EN-US_TOPIC_0000001188110586__b160011119172">ANALYZE</strong> to <strong id="EN-US_TOPIC_0000001188110586__b1185081913171">VACUUM FULL</strong>.</p>
</div></div>
</li><li id="EN-US_TOPIC_0000001188110586__l51b262d8b6b64691b133af48cea732ad"><strong id="EN-US_TOPIC_0000001188110586__a6e9340ced0084094a6ebdaced44baa1b">FREEZE</strong><p id="EN-US_TOPIC_0000001188110586__a58abd6b93c3e4697a898b75d057c04a8">Specifying a <strong id="EN-US_TOPIC_0000001188110586__b9702954125718">FREEZE</strong> is equivalent to setting vacuum_freeze_min_age to <strong id="EN-US_TOPIC_0000001188110586__b652513128587">0</strong> when VACUUM is executed.</p>
</li><li id="EN-US_TOPIC_0000001188110586__l8c7d8b480e4b427ba07e95e817f58f57"><strong id="EN-US_TOPIC_0000001188110586__a88b01d5ef1904ee5b9ebddac91287d87">VERBOSE</strong><p id="EN-US_TOPIC_0000001188110586__a445bdae44d784b2ca1e86c0812f7ad85">Prints a detailed vacuum activity report for each table.</p>
</li><li id="EN-US_TOPIC_0000001188110586__l8bd1eb6b8d9a4be091b980ff32a5004a"><strong id="EN-US_TOPIC_0000001188110586__a3fee0c4c7ceb472dbe7fad548c89c656">ANALYZE | ANALYSE</strong><p id="EN-US_TOPIC_0000001188110586__a246e780aefda41d5a3052589f31d6245">Updates statistics used by the planner to determine the most efficient way to execute a query.</p>
</li><li id="EN-US_TOPIC_0000001188110586__l1ee21fb7ce8a4f0ea39040c12b3c58cd"><strong id="EN-US_TOPIC_0000001188110586__a885f61484dc44005a4c28eb72d84db29">table_name</strong><p id="EN-US_TOPIC_0000001188110586__ad467aa7239404197aa852226a39149c3">Indicates the name (optionally schema-qualified) of a specific table to vacuum.</p>
<p id="EN-US_TOPIC_0000001188110586__ac96f70dcd0cf43e988ca430aaed24ef4">Value range: The name of a specific table to vacuum. Defaults are all tables in the current database.</p>
</li><li id="EN-US_TOPIC_0000001188110586__l37a69e2ca3054404a702f6248fc8986a"><strong id="EN-US_TOPIC_0000001188110586__a846e9d4698074065a002ad3e6e1ce0bd">column_name</strong><p id="EN-US_TOPIC_0000001188110586__a0e6052d387de4ed0807902e51eff4869">Indicates the name of a specific field to analyze.</p>
<p id="EN-US_TOPIC_0000001188110586__a67e50e8ba0344c5fbc676abb00b57468">Value range: Indicates the name of a specific field to analyze. Defaults are all columns.</p>
</li><li id="EN-US_TOPIC_0000001188110586__l541d88b952e3461b8646e75f31ba15bc"><strong id="EN-US_TOPIC_0000001188110586__a18bf6d74016845a7823a354e5d67c1aa">PARTITION</strong><p id="EN-US_TOPIC_0000001188110586__a791c43e8c9c444548bc992651a684f97">HDFS table does not support <strong id="EN-US_TOPIC_0000001188110586__b118679643916565">PARTITION</strong>. <strong id="EN-US_TOPIC_0000001188110586__b1386083275165546">COMPACT</strong> and <strong id="EN-US_TOPIC_0000001188110586__b450013450165546">PARTITION</strong> cannot be used at the same time.</p>
<div class="note" id="EN-US_TOPIC_0000001188110586__note11898153111182"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="EN-US_TOPIC_0000001188110586__p88981031101819">If the <strong id="EN-US_TOPIC_0000001188110586__b225711295581">PARTITION</strong> and <strong id="EN-US_TOPIC_0000001188110586__b16897123116587">COMPACT</strong> parameters are used at the same time, the following error message is displayed: <strong id="EN-US_TOPIC_0000001188110586__b1215605615819">COMPACT can not be used with PARTITION</strong>.</p>
</div></div>
</li><li id="EN-US_TOPIC_0000001188110586__lb45a48b077ef4938aa8e27258f330009"><strong id="EN-US_TOPIC_0000001188110586__a39f9f7f6a0dc4547831d898d6d2030eb">partition_name</strong><p id="EN-US_TOPIC_0000001188110586__a71e10e8f0fad44068e7157c014b747dc">Indicates the partition name of a specific table to vacuum. Defaults are all partitions.</p>
</li><li id="EN-US_TOPIC_0000001188110586__l39da84c8002046578a19e9c44ca4f025"><strong id="EN-US_TOPIC_0000001188110586__a8dc44d683b564b13a31a144b298b53d8">DELTAMERGE</strong><p id="EN-US_TOPIC_0000001188110586__ab4de1ceec20b46d6901f5c3762f66994">(For HDFS tables) Migrates data from the delta table to primary tables. If the data volume of the delta table is less than 60,000 rows, the data will not be migrated. Otherwise, the data will be migrated to HDFS, and the delta table will be cleared by <strong id="EN-US_TOPIC_0000001188110586__b12490613142218">TRUNCATE</strong>. </p>
</li><li id="EN-US_TOPIC_0000001188110586__leb71aec9ff894fe59875a6eb504d9b21"><strong id="EN-US_TOPIC_0000001188110586__a2f797b6c271c4025bbc29fc9eea5ecbc">HDFSDIRECTORY</strong><p id="EN-US_TOPIC_0000001188110586__a8aa91fe0414e48b4b43eb784e23a8bca">Deletes the empty value partition directory of HDFS table in HDFS storage for HDFS table.</p>
</li></ul>
</div>
<div class="section" id="EN-US_TOPIC_0000001188110586__s12262122d2d24f618cc6d20821bd0807"><h4 class="sectiontitle">Examples</h4><div class="p" id="EN-US_TOPIC_0000001188110586__p3572185142311">Create a partitioned table <strong id="EN-US_TOPIC_0000001188110586__b9572052121510">customer_address</strong>:<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001188110586__screen55110301922"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal"> 1</span>
<span class="normal"> 2</span>
<span class="normal"> 3</span>
<span class="normal"> 4</span>
<span class="normal"> 5</span>
<span class="normal"> 6</span>
<span class="normal"> 7</span>
<span class="normal"> 8</span>
<span class="normal"> 9</span>
<span class="normal">10</span>
<span class="normal">11</span>
<span class="normal">12</span>
<span class="normal">13</span>
<span class="normal">14</span>
<span class="normal">15</span>
<span class="normal">16</span>
<span class="normal">17</span>
<span class="normal">18</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">DROP</span><span class="w"> </span><span class="k">TABLE</span><span class="w"> </span><span class="k">IF</span><span class="w"> </span><span class="k">EXISTS</span><span class="w"> </span><span class="n">customer_address</span><span class="p">;</span>
<span class="k">CREATE</span><span class="w"> </span><span class="k">TABLE</span><span class="w"> </span><span class="n">customer_address</span>
<span class="p">(</span>
<span class="w"> </span><span class="n">ca_address_sk</span><span class="w"> </span><span class="nb">INTEGER</span><span class="w"> </span><span class="k">NOT</span><span class="w"> </span><span class="k">NULL</span><span class="w"> </span><span class="p">,</span>
<span class="w"> </span><span class="n">ca_address_id</span><span class="w"> </span><span class="nb">CHARACTER</span><span class="p">(</span><span class="mi">16</span><span class="p">)</span><span class="w"> </span><span class="k">NOT</span><span class="w"> </span><span class="k">NULL</span><span class="w"> </span><span class="p">,</span>
<span class="w"> </span><span class="n">ca_street_number</span><span class="w"> </span><span class="nb">CHARACTER</span><span class="p">(</span><span class="mi">10</span><span class="p">)</span><span class="w"> </span><span class="p">,</span>
<span class="w"> </span><span class="n">ca_street_name</span><span class="w"> </span><span class="nb">CHARACTER</span><span class="w"> </span><span class="nb">varying</span><span class="p">(</span><span class="mi">60</span><span class="p">)</span><span class="w"> </span><span class="p">,</span>
<span class="w"> </span><span class="n">ca_street_type</span><span class="w"> </span><span class="nb">CHARACTER</span><span class="p">(</span><span class="mi">15</span><span class="p">)</span><span class="w"> </span><span class="p">,</span>
<span class="w"> </span><span class="n">ca_suite_number</span><span class="w"> </span><span class="nb">CHARACTER</span><span class="p">(</span><span class="mi">10</span><span class="p">)</span><span class="w"> </span>
<span class="p">)</span>
<span class="n">DISTRIBUTE</span><span class="w"> </span><span class="k">BY</span><span class="w"> </span><span class="n">HASH</span><span class="w"> </span><span class="p">(</span><span class="n">ca_address_sk</span><span class="p">)</span>
<span class="n">PARTITION</span><span class="w"> </span><span class="k">BY</span><span class="w"> </span><span class="n">RANGE</span><span class="p">(</span><span class="n">ca_address_sk</span><span class="p">)</span>
<span class="p">(</span>
<span class="w"> </span><span class="n">PARTITION</span><span class="w"> </span><span class="n">P1</span><span class="w"> </span><span class="k">VALUES</span><span class="w"> </span><span class="k">LESS</span><span class="w"> </span><span class="k">THAN</span><span class="p">(</span><span class="mi">2450815</span><span class="p">),</span>
<span class="w"> </span><span class="n">PARTITION</span><span class="w"> </span><span class="n">P2</span><span class="w"> </span><span class="k">VALUES</span><span class="w"> </span><span class="k">LESS</span><span class="w"> </span><span class="k">THAN</span><span class="p">(</span><span class="mi">2451179</span><span class="p">),</span>
<span class="w"> </span><span class="n">PARTITION</span><span class="w"> </span><span class="n">P3</span><span class="w"> </span><span class="k">VALUES</span><span class="w"> </span><span class="k">LESS</span><span class="w"> </span><span class="k">THAN</span><span class="p">(</span><span class="mi">2451544</span><span class="p">),</span>
<span class="w"> </span><span class="n">PARTITION</span><span class="w"> </span><span class="n">P4</span><span class="w"> </span><span class="k">VALUES</span><span class="w"> </span><span class="k">LESS</span><span class="w"> </span><span class="k">THAN</span><span class="p">(</span><span class="k">MAXVALUE</span><span class="p">)</span>
<span class="p">);</span>
</pre></div></td></tr></table></div>
</div>
</div>
<p id="EN-US_TOPIC_0000001188110586__p12649163574715">Delete all tables in the current database.</p>
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001188110586__screen8649133511474"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">VACUUM</span><span class="p">;</span>
</pre></div></td></tr></table></div>
</div>
<p id="EN-US_TOPIC_0000001188110586__p18386141217413">Reclaim the space of partition <strong id="EN-US_TOPIC_0000001188110586__b1425416471382">P2</strong> of the <strong id="EN-US_TOPIC_0000001188110586__b19260154773819">customer_address</strong> table without updating statistics.</p>
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001188110586__screen6130652195011"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">VACUUM</span><span class="w"> </span><span class="k">FULL</span><span class="w"> </span><span class="n">customer_address</span><span class="w"> </span><span class="n">PARTITION</span><span class="p">(</span><span class="n">P2</span><span class="p">);</span>
</pre></div></td></tr></table></div>
</div>
<p id="EN-US_TOPIC_0000001188110586__p10560366269">Reclaim the space of the <strong id="EN-US_TOPIC_0000001188110586__b2164134214210">customer_address</strong> table and update statistics.</p>
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001188110586__screen1392110247263"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">VACUUM</span><span class="w"> </span><span class="k">FULL</span><span class="w"> </span><span class="k">ANALYZE</span><span class="w"> </span><span class="n">customer_address</span><span class="p">;</span>
</pre></div></td></tr></table></div>
</div>
<p id="EN-US_TOPIC_0000001188110586__p964912356478">Delete all tables in the current database and collect statistics about the query optimizer.</p>
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001188110586__screen19649163517472"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">VACUUM</span><span class="w"> </span><span class="k">ANALYZE</span><span class="p">;</span>
</pre></div></td></tr></table></div>
</div>
<p id="EN-US_TOPIC_0000001188110586__p1464993511478">Delete only the <strong id="EN-US_TOPIC_0000001188110586__b15539185810385">reason</strong> table.</p>
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001188110586__screen3649835124710"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">VACUUM</span><span class="w"> </span><span class="p">(</span><span class="k">VERBOSE</span><span class="p">,</span><span class="w"> </span><span class="k">ANALYZE</span><span class="p">)</span><span class="w"> </span><span class="n">customer_address</span><span class="p">;</span>
</pre></div></td></tr></table></div>
</div>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="dws_06_0118.html">DDL Syntax</a></div>
</div>
</div>