doc-exports/docs/dws/dev/dws_06_0177.html
Lu, Huayi ef0ada5a59 DWS DEV 20240716 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-11-02 09:07:47 +00:00

459 lines
115 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<a name="EN-US_TOPIC_0000001460561348"></a><a name="EN-US_TOPIC_0000001460561348"></a>
<h1 class="topictitle1">CREATE TABLE</h1>
<div id="body8662426"><div class="section" id="EN-US_TOPIC_0000001460561348__sf337ecb5bde84580afed94be7bbf5fb9"><h4 class="sectiontitle">Function</h4><p id="EN-US_TOPIC_0000001460561348__p1479251195413">Creates a new empty table in the current database.</p>
<p id="EN-US_TOPIC_0000001460561348__p2046055112175">This table is owned by the user who executes the command. However, if the system administrator creates a table in the schema with the same name as a common user, the owner of the table is the user (not the system administrator).</p>
</div>
<div class="section" id="EN-US_TOPIC_0000001460561348__s0c57396ef17642e9a39a88ab766472e1"><h4 class="sectiontitle">Precautions</h4><ul id="EN-US_TOPIC_0000001460561348__u833942a091c642dba1f12f016ec573a6"><li id="EN-US_TOPIC_0000001460561348__le903af21ab1644e0b51a936ddbd4c996">For details about the data types supported by column-store tables, see <a href="dws_06_0024.html">Data Types Supported by Column-Store Tables</a>.</li><li id="EN-US_TOPIC_0000001460561348__l504f7aa1a84c4020b9b51a8bff923e10">It is recommended that the number of column-store and HDFS partitioned tables do not exceed 1000.</li><li id="EN-US_TOPIC_0000001460561348__lce538d16b2d64c65ae8ca8377cec854e">The primary key constraint and unique constraint in the table must contain a distribution column.</li><li id="EN-US_TOPIC_0000001460561348__li813613378913">The data type of the distribution column in an existing table cannot be modified.</li><li id="EN-US_TOPIC_0000001460561348__li215845114610">A system column cannot be designated as a primary key in a row-store REPLICATION distributed table.</li><li id="EN-US_TOPIC_0000001460561348__ld83425fa453940b8b1a64221980594cd">If an error occurs during table creation, after it is fixed, the system may fail to delete the empty disk files created before the last automatic clearance. This problem seldom occurs.</li><li id="EN-US_TOPIC_0000001460561348__le8ecab52de30457fbd82700c5935cf14">Column-store tables support the <strong id="EN-US_TOPIC_0000001460561348__b13213192281711">PARTIAL CLUSTER KEY</strong> and table-level primary key and unique constraints, but do not support table-level foreign key constraints.</li><li id="EN-US_TOPIC_0000001460561348__l76076d8dd65d4bee88728948873de834">Only the NULL, NOT NULL, and DEFAULT constant values can be used as column-store table column constraints.</li><li id="EN-US_TOPIC_0000001460561348__li1650612339613">Whether column-store tables support a delta table is specified by the <strong id="EN-US_TOPIC_0000001460561348__b16709154122318">enable_delta</strong> parameter. The threshold for storing data into a delta table is specified by the <strong id="EN-US_TOPIC_0000001460561348__b147101754132315">deltarow_threshold</strong> parameter. Using column-store tables with delta tables is not recommended. This may cause disk bloat and performance deterioration due to delayed merge.</li><li id="EN-US_TOPIC_0000001460561348__li62418531059">Multi-temperature tables support only partitioned column-store tables and depend on available OBS tablespaces.</li><li id="EN-US_TOPIC_0000001460561348__li926141319599">Multi-temperature tables support only the default tablespace <strong id="EN-US_TOPIC_0000001460561348__b1378181413559">default_obs_tbs</strong>. If you need to add an OBS tablespace, contact technical support.</li></ul>
</div>
<div class="section" id="EN-US_TOPIC_0000001460561348__s24f4eafc7fd349969c837eaaf863b260"><h4 class="sectiontitle">Syntax</h4><div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001460561348__s8ca28ce519cb41439fb1df4c043e6e8b"><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></pre></div></td><td class="code"><div><pre><span></span><span class="k">CREATE</span><span class="w"> </span><span class="p">[</span><span class="w"> </span><span class="p">[</span><span class="w"> </span><span class="k">GLOBAL</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="k">LOCAL</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="k">VOLATILE</span><span class="w"> </span><span class="p">]</span><span class="w"> </span><span class="err">{</span><span class="w"> </span><span class="k">TEMPORARY</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="n">TEMP</span><span class="w"> </span><span class="err">}</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="n">UNLOGGED</span><span class="w"> </span><span class="p">]</span><span class="w"> </span><span class="k">TABLE</span><span class="w"> </span><span class="p">[</span><span class="w"> </span><span class="k">IF</span><span class="w"> </span><span class="k">NOT</span><span class="w"> </span><span class="k">EXISTS</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="w"> </span><span class="err">{</span><span class="w"> </span><span class="p">(</span><span class="err">{</span><span class="w"> </span><span class="k">column_name</span><span class="w"> </span><span class="n">data_type</span><span class="w"> </span><span class="p">[</span><span class="w"> </span><span class="n">compress_mode</span><span class="w"> </span><span class="p">]</span><span class="w"> </span><span class="p">[</span><span class="w"> </span><span class="k">COLLATE</span><span class="w"> </span><span class="k">collation</span><span class="w"> </span><span class="p">]</span><span class="w"> </span><span class="p">[</span><span class="w"> </span><span class="n">column_constraint</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="o">|</span><span class="w"> </span><span class="n">table_constraint</span>
<span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="k">LIKE</span><span class="w"> </span><span class="n">source_table</span><span class="w"> </span><span class="p">[</span><span class="w"> </span><span class="n">like_option</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="p">[,</span><span class="w"> </span><span class="p">...</span><span class="w"> </span><span class="p">])</span><span class="o">|</span>
<span class="w"> </span><span class="k">LIKE</span><span class="w"> </span><span class="n">source_table</span><span class="w"> </span><span class="p">[</span><span class="w"> </span><span class="n">like_option</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="w"> </span><span class="p">[</span><span class="w"> </span><span class="k">WITH</span><span class="w"> </span><span class="p">(</span><span class="w"> </span><span class="err">{</span><span class="n">storage_parameter</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">value</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="p">]</span>
<span class="w"> </span><span class="p">[</span><span class="w"> </span><span class="k">ON</span><span class="w"> </span><span class="k">COMMIT</span><span class="w"> </span><span class="err">{</span><span class="w"> </span><span class="k">PRESERVE</span><span class="w"> </span><span class="k">ROWS</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="k">DELETE</span><span class="w"> </span><span class="k">ROWS</span><span class="w"> </span><span class="p">]</span>
<span class="w"> </span><span class="p">[</span><span class="w"> </span><span class="n">COMPRESS</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="n">NOCOMPRESS</span><span class="w"> </span><span class="p">]</span>
<span class="w"> </span><span class="p">[</span><span class="w"> </span><span class="n">DISTRIBUTE</span><span class="w"> </span><span class="k">BY</span><span class="w"> </span><span class="err">{</span><span class="w"> </span><span class="n">REPLICATION</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="n">ROUNDROBIN</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="err">{</span><span class="w"> </span><span class="n">HASH</span><span class="w"> </span><span class="p">(</span><span class="w"> </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="err">}</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="k">TO</span><span class="w"> </span><span class="err">{</span><span class="w"> </span><span class="k">GROUP</span><span class="w"> </span><span class="n">groupname</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="n">NODE</span><span class="w"> </span><span class="p">(</span><span class="w"> </span><span class="n">nodename</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="err">}</span><span class="w"> </span><span class="p">]</span>
<span class="w"> </span><span class="p">[</span><span class="w"> </span><span class="k">COMMENT</span><span class="w"> </span><span class="p">[</span><span class="o">=</span><span class="p">]</span><span class="w"> </span><span class="s1">'text'</span><span class="w"> </span><span class="p">];</span>
</pre></div></td></tr></table></div>
</div>
<ul id="EN-US_TOPIC_0000001460561348__u51eab43ce2b24d86b3e1d981e21fa644"><li id="EN-US_TOPIC_0000001460561348__l4f184948a45942409141cdb1165b3d81"><strong id="EN-US_TOPIC_0000001460561348__b84235270610227">column_constraint</strong> is as follows:<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001460561348__s6e3304ced7c14e75bb0f63b2af33255f"><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></pre></div></td><td class="code"><div><pre><span></span><span class="p">[</span><span class="w"> </span><span class="k">CONSTRAINT</span><span class="w"> </span><span class="k">constraint_name</span><span class="w"> </span><span class="p">]</span>
<span class="err">{</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="o">|</span>
<span class="w"> </span><span class="k">NULL</span><span class="w"> </span><span class="o">|</span>
<span class="w"> </span><span class="k">CHECK</span><span class="w"> </span><span class="p">(</span><span class="w"> </span><span class="n">expression</span><span class="w"> </span><span class="p">)</span><span class="w"> </span><span class="o">|</span>
<span class="w"> </span><span class="k">DEFAULT</span><span class="w"> </span><span class="n">default_expr</span><span class="w"> </span><span class="o">|</span>
<span class="w"> </span><span class="k">ON</span><span class="w"> </span><span class="k">UPDATE</span><span class="w"> </span><span class="n">on_update_expr</span><span class="w"> </span><span class="o">|</span>
<span class="w"> </span><span class="k">COMMENT</span><span class="w"> </span><span class="s1">'text'</span><span class="w"> </span><span class="o">|</span>
<span class="w"> </span><span class="k">UNIQUE</span><span class="w"> </span><span class="p">[</span><span class="w"> </span><span class="n">NULLS</span><span class="w"> </span><span class="p">[</span><span class="k">NOT</span><span class="p">]</span><span class="w"> </span><span class="k">DISTINCT</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="n">NULLS</span><span class="w"> </span><span class="k">IGNORE</span><span class="w"> </span><span class="p">]</span><span class="w"> </span><span class="n">index_parameters</span><span class="w"> </span><span class="o">|</span>
<span class="w"> </span><span class="k">PRIMARY</span><span class="w"> </span><span class="k">KEY</span><span class="w"> </span><span class="n">index_parameters</span><span class="w"> </span><span class="err">}</span>
<span class="p">[</span><span class="w"> </span><span class="k">DEFERRABLE</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="k">NOT</span><span class="w"> </span><span class="k">DEFERRABLE</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="k">INITIALLY</span><span class="w"> </span><span class="k">DEFERRED</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="k">INITIALLY</span><span class="w"> </span><span class="k">IMMEDIATE</span><span class="w"> </span><span class="p">]</span>
</pre></div></td></tr></table></div>
</div>
</li></ul>
<ul id="EN-US_TOPIC_0000001460561348__u070f826fe6544b61872abf44e6512111"><li id="EN-US_TOPIC_0000001460561348__l072891e7e4844f89bf28ecb50eee1b74"><strong id="EN-US_TOPIC_0000001460561348__b842352706171324">compress_mode</strong> of a column is as follows:<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001460561348__s9c4ebbb1c85f409fac6f0b278c7f83b0"><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="err">{</span><span class="w"> </span><span class="n">DELTA</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="k">PREFIX</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="k">DICTIONARY</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="n">NUMSTR</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="n">NOCOMPRESS</span><span class="w"> </span><span class="err">}</span>
</pre></div></td></tr></table></div>
</div>
</li><li id="EN-US_TOPIC_0000001460561348__l5447f854591b42e1a0b28e890cf928d1"><strong id="EN-US_TOPIC_0000001460561348__b84235270610618">table_constraint</strong> is as follows:<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001460561348__sf70e656023dc48a39b64c1b6433acc71"><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></pre></div></td><td class="code"><div><pre><span></span><span class="p">[</span><span class="w"> </span><span class="k">CONSTRAINT</span><span class="w"> </span><span class="k">constraint_name</span><span class="w"> </span><span class="p">]</span>
<span class="err">{</span><span class="w"> </span><span class="k">CHECK</span><span class="w"> </span><span class="p">(</span><span class="w"> </span><span class="n">expression</span><span class="w"> </span><span class="p">)</span><span class="w"> </span><span class="o">|</span>
<span class="w"> </span><span class="k">UNIQUE</span><span class="w"> </span><span class="p">[</span><span class="w"> </span><span class="n">NULLS</span><span class="w"> </span><span class="p">[</span><span class="k">NOT</span><span class="p">]</span><span class="w"> </span><span class="k">DISTINCT</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="n">NULLS</span><span class="w"> </span><span class="k">IGNORE</span><span class="w"> </span><span class="p">]</span><span class="w"> </span><span class="p">(</span><span class="w"> </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="n">index_parameters</span><span class="w"> </span><span class="o">|</span>
<span class="w"> </span><span class="k">PRIMARY</span><span class="w"> </span><span class="k">KEY</span><span class="w"> </span><span class="p">(</span><span class="w"> </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="n">index_parameters</span><span class="w"> </span><span class="o">|</span>
<span class="w"> </span><span class="k">PARTIAL</span><span class="w"> </span><span class="k">CLUSTER</span><span class="w"> </span><span class="k">KEY</span><span class="w"> </span><span class="p">(</span><span class="w"> </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="err">}</span>
<span class="p">[</span><span class="w"> </span><span class="k">DEFERRABLE</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="k">NOT</span><span class="w"> </span><span class="k">DEFERRABLE</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="k">INITIALLY</span><span class="w"> </span><span class="k">DEFERRED</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="k">INITIALLY</span><span class="w"> </span><span class="k">IMMEDIATE</span><span class="w"> </span><span class="p">]</span>
</pre></div></td></tr></table></div>
</div>
</li></ul>
<ul id="EN-US_TOPIC_0000001460561348__u147ed9cab742413da2c22e8026d659ec"><li id="EN-US_TOPIC_0000001460561348__l8cb55d220954403088edf67e4e32f784"><strong id="EN-US_TOPIC_0000001460561348__b84235270610642">like_option</strong> is as follows:<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001460561348__s67c0d2d2f5a04e7ba423354a916bf185"><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="err">{</span><span class="w"> </span><span class="k">INCLUDING</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="k">EXCLUDING</span><span class="w"> </span><span class="err">}</span><span class="w"> </span><span class="err">{</span><span class="w"> </span><span class="k">DEFAULTS</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="k">CONSTRAINTS</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="n">INDEXES</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="k">STORAGE</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="n">COMMENTS</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="n">PARTITION</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="n">RELOPTIONS</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="n">DISTRIBUTION</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="n">DROPCOLUMNS</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="k">ALL</span><span class="w"> </span><span class="err">}</span>
</pre></div></td></tr></table></div>
</div>
</li><li id="EN-US_TOPIC_0000001460561348__li04965417494"><strong id="EN-US_TOPIC_0000001460561348__b8423527069548">index_parameters</strong> is as follows:<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001460561348__s5d41cbc0c47d433397704f5f3f596bb4"><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="p">[</span><span class="w"> </span><span class="k">WITH</span><span class="w"> </span><span class="p">(</span><span class="w"> </span><span class="err">{</span><span class="n">storage_parameter</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">value</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="p">]</span>
</pre></div></td></tr></table></div>
</div>
</li></ul>
</div>
<div class="section" id="EN-US_TOPIC_0000001460561348__s1a0c1ce222bb46dfb68a016610aea3a5"><h4 class="sectiontitle">Parameters</h4><ul id="EN-US_TOPIC_0000001460561348__u4a81a0d707ae45068ea150166c1b249d"><li id="EN-US_TOPIC_0000001460561348__lf971c986fe2e4125be8a8f625f6affd5"><strong id="EN-US_TOPIC_0000001460561348__a4ee5d12f41554c0a8148e84e32b06679">UNLOGGED</strong><p id="EN-US_TOPIC_0000001460561348__a80f651f260324dd4bf991e108fe3a63a">If this key word is specified, the created table is not a log table. Data written to unlogged tables is not written to the write-ahead log, which makes them considerably faster than ordinary tables. However, an unlogged table is automatically truncated after a crash or unclean shutdown, incurring data loss risks. The contents of an unlogged table are also not replicated to standby servers. Any indexes created on an unlogged table are not automatically logged as well.</p>
<p id="EN-US_TOPIC_0000001460561348__aa033b20b81a042e9b41d306fa692ad2b">Usage scenario: Unlogged tables do not ensure safe data. Users can back up data before using unlogged tables; for example, users should back up the data before a system upgrade.</p>
<p id="EN-US_TOPIC_0000001460561348__a2f1c759659684f7394c49bb0ca2b0412">Troubleshooting: If data is missing in the indexes of unlogged tables due to some unexpected operations such as an unclean shutdown, users should re-create the indexes with errors.</p>
<div class="notice" id="EN-US_TOPIC_0000001460561348__note6872102415351"><span class="noticetitle"><img src="public_sys-resources/notice_3.0-en-us.png"> </span><div class="noticebody"><p id="EN-US_TOPIC_0000001460561348__p17172193014350">The UNLOGGED table uses no primary/standby mechanism. In the case of system faults or abnormal breakpoints, data loss may occur. Therefore, the UNLOGGED table cannot be used to store basic data.</p>
</div></div>
</li><li id="EN-US_TOPIC_0000001460561348__l40601c13ccdb4b5d85be38edd4f99676"><a name="EN-US_TOPIC_0000001460561348__l40601c13ccdb4b5d85be38edd4f99676"></a><a name="l40601c13ccdb4b5d85be38edd4f99676"></a><strong id="EN-US_TOPIC_0000001460561348__a89e3dc3abfac4c428089799d71037e02">GLOBAL | LOCAL</strong> | <strong id="EN-US_TOPIC_0000001460561348__b18097713339">VOLATILE</strong><p id="EN-US_TOPIC_0000001460561348__p23435388815">Specify the keywords <strong id="EN-US_TOPIC_0000001460561348__b83181813235">GLOBAL</strong>, <strong id="EN-US_TOPIC_0000001460561348__b1552921102311">LOCAL</strong>, and <strong id="EN-US_TOPIC_0000001460561348__b1895412402315">VOLATILE</strong> before <strong id="EN-US_TOPIC_0000001460561348__b1385912321239">TEMP</strong> or <strong id="EN-US_TOPIC_0000001460561348__b177113710232">TEMPORARY</strong> to create temporary tables with different attributes.</p>
<ul id="EN-US_TOPIC_0000001460561348__ul27695398547"><li id="EN-US_TOPIC_0000001460561348__li084515396354">Currently, the keywords <strong id="EN-US_TOPIC_0000001460561348__b1053858216103716">GLOBAL</strong> and <strong id="EN-US_TOPIC_0000001460561348__b1467951852103716">LOCAL</strong> are introduced for standard SQL compatibility. No matter whether <strong id="EN-US_TOPIC_0000001460561348__b337519173103716">GLOBAL</strong> or <strong id="EN-US_TOPIC_0000001460561348__b1724242343103716">LOCAL</strong> is specified, the <span id="EN-US_TOPIC_0000001460561348__text1549930766103716">GaussDB(DWS)</span> creates a LOCAL temporary table.</li><li id="EN-US_TOPIC_0000001460561348__li2039414965517">If <strong id="EN-US_TOPIC_0000001460561348__b1441252112516">VOLATILE</strong> is specified, a temporary volatile table is created.</li></ul>
</li><li id="EN-US_TOPIC_0000001460561348__la8c031f4e4834cb0a68578e03dfdc407"><strong id="EN-US_TOPIC_0000001460561348__ad29cbd42d25f431baea8a5372eb9688a">TEMPORARY | TEMP</strong><p id="EN-US_TOPIC_0000001460561348__ade96caf3b58a440e9f1bc1815a7aa881">If <strong id="EN-US_TOPIC_0000001460561348__b842352706214543">TEMP</strong> or <strong id="EN-US_TOPIC_0000001460561348__b842352706214547">TEMPORARY</strong> is specified, the created table is a temporary table. Temporary tables are automatically dropped at the end of a session, or optionally at the end of the current transaction. Therefore, apart from CN and other CN errors connected by the current session, you can still create and use temporary table in the current session. Temporary tables are created only in the current session. If a DDL statement involves operations on temporary tables, a DDL error will be generated. Therefore, you are not advised to perform operations on temporary tables in DDL statements. <strong id="EN-US_TOPIC_0000001460561348__b8423527069813">TEMP</strong> is equivalent to <strong id="EN-US_TOPIC_0000001460561348__b8423527069818">TEMPORARY</strong>.</p>
<div class="notice" id="EN-US_TOPIC_0000001460561348__n6e16cd1e50d04bedbca2c396dfc17987"><span class="noticetitle"><img src="public_sys-resources/notice_3.0-en-us.png"> </span><div class="noticebody"><ul id="EN-US_TOPIC_0000001460561348__u4169b31d76e341d8bcf794eb1894a35c"><li id="EN-US_TOPIC_0000001460561348__lf03d0d8803e4428b9429afd47e61ca02">Local or volatile temporary tables are visible to the current session through schema of the <strong id="EN-US_TOPIC_0000001460561348__b8423527069832">pg_temp</strong> start. Users should not delete schema started with <strong id="EN-US_TOPIC_0000001460561348__b8423527069846">pg_temp</strong>, <strong id="EN-US_TOPIC_0000001460561348__b8423527069851">pg_toast_temp</strong>.</li><li id="EN-US_TOPIC_0000001460561348__l08317ce8988e468486b25577e2c864ff">If <strong id="EN-US_TOPIC_0000001460561348__b842352706994">TEMPORARY</strong> or <strong id="EN-US_TOPIC_0000001460561348__b512478272214747">TEMP</strong> is not specified when you create a table and the schema of the specified table starts with <strong id="EN-US_TOPIC_0000001460561348__b8423527069915">pg_temp_</strong>, the table is created as a temporary table.</li><li id="EN-US_TOPIC_0000001460561348__li8292020144419">Similar to common tables, all metadata of local temporary tables is stored in system catalogs. Volatile temporary tables store table structure metadata in memory, except the schema metadata. Compared with local temporary tables, volatile temporary tables have the following constraints:<ul id="EN-US_TOPIC_0000001460561348__ul17375184116578"><li id="EN-US_TOPIC_0000001460561348__li13401164018576">After a CN or DN is restarted, data in its memory will be lost, and accordingly, volatile temporary tables on it will become invalid.</li><li id="EN-US_TOPIC_0000001460561348__li18190645102317">Currently, volatile temporary tables do not support table structure modification, such as <strong id="EN-US_TOPIC_0000001460561348__b145641419811">ALTER</strong> and <strong id="EN-US_TOPIC_0000001460561348__b49143189813">GRANT</strong>.</li><li id="EN-US_TOPIC_0000001460561348__li11383113662419">Volatile temporary tables and local temporary tables share temporary schemas. Therefore, in the same session, the VOLATILE temporary table and local temporary table cannot have the same name.</li><li id="EN-US_TOPIC_0000001460561348__li89011412142611">Volatile temporary table information is not stored in system catalogs. Therefore, Volatile metadata cannot be queried by running DML statements in system catalogs.</li><li id="EN-US_TOPIC_0000001460561348__li16271340162720">Volatile temporary tables support only common row-store and column-store tables. Delta tables, time series tables, and cold and hot tables are not supported.</li><li id="EN-US_TOPIC_0000001460561348__li896615592810">Views cannot be created based on volatile temporary tables.</li><li id="EN-US_TOPIC_0000001460561348__li29991602917">A tablespace cannot be specified when a temporary table is created. The default tablespace of a volatile temporary table is <strong id="EN-US_TOPIC_0000001460561348__b19991650184919">pg_volatile</strong>.</li><li id="EN-US_TOPIC_0000001460561348__li5242201533520">The following constraints cannot be specified when a volatile temporary table is created: CHECK, UNIQUE, PRIMARY KEY, TRIGGER, EXCLUDE, and PARTIAL CLUSTER.</li></ul>
</li></ul>
</div></div>
</li><li id="EN-US_TOPIC_0000001460561348__lc929efc9948741d3a177e98a1aefbbe4"><strong id="EN-US_TOPIC_0000001460561348__ac4c814ddf6754cd98d7ea10b7d3471f4">IF NOT EXISTS</strong><p id="EN-US_TOPIC_0000001460561348__a907e52a2875c4303b296eb9192898111">If <strong id="EN-US_TOPIC_0000001460561348__b1961294012926">IF NOT EXISTS</strong> is specified, a table will be created if there is no table using the specified name. If there is already a table using the specified name, no error will be reported. A message will be displayed indicating that the table already exists, and the database will skip table creation.</p>
</li><li id="EN-US_TOPIC_0000001460561348__lcacb45adeaab4dc690fff7670c8f1068"><strong id="EN-US_TOPIC_0000001460561348__accc4048091f74784a4329b2cff3870a2">table_name</strong><p id="EN-US_TOPIC_0000001460561348__a69479c547933434eb9ef0c547a2090dc">Specifies the name of the table to be created.</p>
<p id="EN-US_TOPIC_0000001460561348__p2293122101411">The table name can contain a maximum of 63 characters, including letters, digits, underscores (_), dollar signs ($), and number signs (#). It must start with a letter or underscore (_).</p>
<p id="EN-US_TOPIC_0000001460561348__p83351350162712">A table name enclosed in double quotation marks can contain spaces and special characters. However, you are not advised to use these characters in a table name because they may make it difficult to reference and use. In addition, they may be processed differently under different database compatibility modes.</p>
</li><li id="EN-US_TOPIC_0000001460561348__l9617e926aec24a75b2c2472789705e99"><strong id="EN-US_TOPIC_0000001460561348__a114c6e26ec294f52a3fd16a29bb91ae6">column_name</strong><p id="EN-US_TOPIC_0000001460561348__a77a2b66dd4fa4e4099ffaa5c2233ffdb">Specifies the name of a column to be created in the new table.</p>
<p id="EN-US_TOPIC_0000001460561348__p231214106142">The column name can contain a maximum of 63 characters, including letters, digits, underscores (_), dollar signs ($), and number signs (#). It must start with a letter or underscore (_).</p>
</li><li id="EN-US_TOPIC_0000001460561348__l34f1a566739c48b4be821481538f5b81"><strong id="EN-US_TOPIC_0000001460561348__abf296480d6a249bfb6cf296a54adef2a">data_type</strong><p id="EN-US_TOPIC_0000001460561348__a2f57ce2d5cdb4c4d82556493aca949db">Specifies the data type of the column.</p>
<div class="note" id="EN-US_TOPIC_0000001460561348__note57291658143719"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="EN-US_TOPIC_0000001460561348__p20729195803714">In a database that is compatible with Teradata or MySQL syntax, if the data type of a column is set to DATE, the DATE type is returned. Otherwise, the TIMESTAMP type is returned.</p>
</div></div>
</li><li id="EN-US_TOPIC_0000001460561348__leae9e2e4c3b24cbc840a63fac26967bf"><strong id="EN-US_TOPIC_0000001460561348__abb452499ba06468a92aee28041dc612b">compress_mode</strong><p id="EN-US_TOPIC_0000001460561348__a5c5138063921460d8f0c10e4836ac142">Specifies the compress option of the table, only available for row-store table. The option specifies the algorithm preferentially used by table columns.</p>
<p id="EN-US_TOPIC_0000001460561348__a1d9fc64d6a0c41129e29c2739c6cd491">Value range: DELTA, PREFIX, DICTIONARY, NUMSTR, NOCOMPRESS</p>
</li><li id="EN-US_TOPIC_0000001460561348__l8833e8a37d8847e6a084aaa436a4785a"><strong id="EN-US_TOPIC_0000001460561348__a33d7e7f0a2f7440da6ad45191a997bc3">COLLATE collation</strong><p id="EN-US_TOPIC_0000001460561348__a83a9b3e7f11c48a7b26c5b90ef24b278">Assigns a collation to the column (which must be of a collatable data type). If no collation is specified, the default collation is used.</p>
</li><li id="EN-US_TOPIC_0000001460561348__l9f8eff5559b14ec7a69c0966fd7ebeae"><strong id="EN-US_TOPIC_0000001460561348__aac04cbe8532f40a4a75f915be05075d6">LIKE source_table [ like_option ... ]</strong><p id="EN-US_TOPIC_0000001460561348__ade1c6728f97a42d69c2fd4e170dcb5d2">Specifies a table from which the new table automatically copies all column names, their data types, and their not-null constraints.</p>
<p id="EN-US_TOPIC_0000001460561348__acbeb69fb11e142a79b4be1d441ba85b0">The new table and the source table are decoupled after creation is complete. Changes to the source table will not be applied to the new table, and it is not possible to include data of the new table in scans of the source table.</p>
<p id="EN-US_TOPIC_0000001460561348__a82dec42153404e0aa7bd8292fb41bad2">Columns and constraints copied by <strong id="EN-US_TOPIC_0000001460561348__b366873831783">LIKE</strong> are not merged with the same name. If the same name is specified explicitly or in another <strong id="EN-US_TOPIC_0000001460561348__b617509951783">LIKE</strong> clause, an error is reported.</p>
<ul id="EN-US_TOPIC_0000001460561348__u4ceb5f7c91f34aec96c9096ba1b9e166"><li id="EN-US_TOPIC_0000001460561348__l8ec43792af1e4657821db87fa1ee418b">The default expressions or the <strong id="EN-US_TOPIC_0000001460561348__b125051445184512">ON UPDATE</strong> expressions are copied from the source table to the new table only if <strong id="EN-US_TOPIC_0000001460561348__b84235270622257">INCLUDING DEFAULTS</strong> is specified. The default behavior is to exclude default expressions, resulting in the copied columns in the new table having default values <strong id="EN-US_TOPIC_0000001460561348__b15257491783">NULL</strong>.</li><li id="EN-US_TOPIC_0000001460561348__la1710617a89e4f4facb17d14d7bd42ff">The <strong id="EN-US_TOPIC_0000001460561348__b84235270622331">CHECK</strong> constraints are copied from the source table to the new table only when <strong id="EN-US_TOPIC_0000001460561348__b18927170822323">INCLUDING CONSTRAINTS</strong> is specified. Other types of constraints are never copied to the new table. <strong id="EN-US_TOPIC_0000001460561348__b49569357317">NOT NULL</strong> constraints are always copied to the new table. These rules also apply to column constraints and table constraints.</li><li id="EN-US_TOPIC_0000001460561348__l168e3a37406543daaca47673b43bcb21">Any indexes on the source table will not be created on the new table, unless the <strong id="EN-US_TOPIC_0000001460561348__en-us_topic_0058965796_b84235270611020">INCLUDING INDEXES</strong> clause is specified.</li><li id="EN-US_TOPIC_0000001460561348__l7f54e2e77bfb4e84a46e60847e15a9e8">STORAGE settings for the copied column definitions are copied only if <strong id="EN-US_TOPIC_0000001460561348__b84235270611028">INCLUDING STORAGE</strong> is specified. The default behavior is to exclude <strong id="EN-US_TOPIC_0000001460561348__b84235270611036">STORAGE</strong> settings.</li><li id="EN-US_TOPIC_0000001460561348__l00432959a35c499cbb32921fbeb51566">If <strong id="EN-US_TOPIC_0000001460561348__b27419559122947">INCLUDING COMMENTS</strong> is specified, comments for the copied columns, constraints, and indexes are copied. The default behavior is to exclude comments.</li><li id="EN-US_TOPIC_0000001460561348__l78294dafebc644a399f057babb13af76">If <strong id="EN-US_TOPIC_0000001460561348__b162321126145310">INCLUDING PARTITION</strong> is specified, the partition definitions of the source table are copied to the new table, and the new table no longer uses the <strong id="EN-US_TOPIC_0000001460561348__b15238226115318">PARTITION BY</strong> clause. The default behavior is to exclude partition definition of the source table.</li><li id="EN-US_TOPIC_0000001460561348__li056717401121">If <strong id="EN-US_TOPIC_0000001460561348__b84235270611052">INCLUDING RELOPTIONS</strong> is specified, the storage parameter (<strong id="EN-US_TOPIC_0000001460561348__b8423527061111">WITH</strong> clause of the source table) of the source table is copied to the new table. The default behavior is to exclude partition definition of the storage parameter of the source table.<div class="note" id="EN-US_TOPIC_0000001460561348__note1553119400128"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="EN-US_TOPIC_0000001460561348__p10531940161217"><strong id="EN-US_TOPIC_0000001460561348__b1310505010364">PERIOD</strong> and <strong id="EN-US_TOPIC_0000001460561348__b112811953113613">TTL</strong> in the <strong id="EN-US_TOPIC_0000001460561348__b188961759133610">WITH</strong> clause are partition-related parameters. <strong id="EN-US_TOPIC_0000001460561348__b82092249378">LIKE INCLUDING RELOPTIONS</strong> will not be copied to the new table. To copy <strong id="EN-US_TOPIC_0000001460561348__b1173833444010">LIKE INCLUDING RELOPTIONS</strong>, use <strong id="EN-US_TOPIC_0000001460561348__b18168154134014">INCLUDING PARTITION</strong>.</p>
</div></div>
</li><li id="EN-US_TOPIC_0000001460561348__l5b63aefd78b048608255c5d45e1f2e59">If <strong id="EN-US_TOPIC_0000001460561348__b8423527061116">INCLUDING DISTRIBUTION</strong> is specified, the distribution information of the source table is copied to the new table, including distribution type and column, and the new table no longer use the <strong id="EN-US_TOPIC_0000001460561348__b84235270611111">DISTRIBUTE BY</strong> clause. The default behavior is to exclude distribution information of the source table.</li><li id="EN-US_TOPIC_0000001460561348__li640611365015">If <strong id="EN-US_TOPIC_0000001460561348__b214210495552">INCLUDING DROPCOLUMNS</strong> is specified, the deleted column information in the source table is copied to the new table. By default, the deleted column information of the source table is not copied.</li><li id="EN-US_TOPIC_0000001460561348__l10d4feca9efc478e8f8cdd64578db5ea"><strong id="EN-US_TOPIC_0000001460561348__b84235270622158">INCLUDING ALL</strong> contains the meaning of <strong id="EN-US_TOPIC_0000001460561348__b842352706221511">INCLUDING DEFAULTS</strong>, <strong id="EN-US_TOPIC_0000001460561348__b842352706221515">INCLUDING CONSTRAINTS</strong>, <strong id="EN-US_TOPIC_0000001460561348__b842352706221518">INCLUDING INDEXES</strong>, <strong id="EN-US_TOPIC_0000001460561348__b842352706221522">INCLUDING STORAGE</strong>, <strong id="EN-US_TOPIC_0000001460561348__b842352706221524">INCLUDING COMMENTS</strong>, <strong id="EN-US_TOPIC_0000001460561348__b842352706221528">INCLUDING PARTITION</strong>, <strong id="EN-US_TOPIC_0000001460561348__b842352706221530">INCLUDING RELOPTIONS</strong>, <strong id="EN-US_TOPIC_0000001460561348__b41672044105610">INCLUDING DISTRIBUTION</strong>, and <strong id="EN-US_TOPIC_0000001460561348__b171901013145718">INCLUDING DROPCOLUMNS</strong>. </li><li id="EN-US_TOPIC_0000001460561348__li153101438375">If EXCLUDING is specified, the specified parameters are not included.</li><li id="EN-US_TOPIC_0000001460561348__li37468519720">For an OBS multi-temperature table, all partitions of the new table are local hot partitions after <strong id="EN-US_TOPIC_0000001460561348__b17657113413254">INCLUDING PARTITION</strong> is specified.</li></ul>
<div class="notice" id="EN-US_TOPIC_0000001460561348__note114471820913"><span class="noticetitle"><img src="public_sys-resources/notice_3.0-en-us.png"> </span><div class="noticebody"><ul id="EN-US_TOPIC_0000001460561348__ul1245114202012"><li id="EN-US_TOPIC_0000001460561348__li645813202111">If the source table contains a sequence with the SERIAL, BIGSERIAL, or SMALLSERIAL data type, or a column in the source table is a sequence by default and the sequence is created for this table by using <strong id="EN-US_TOPIC_0000001460561348__b109261555111211">CREATE SEQUENCE...</strong> <strong id="EN-US_TOPIC_0000001460561348__b76032129814">OWNED BY</strong>, these sequences will not be copied to the new table, and another sequence specific to the new table will be created. This is different from earlier versions. To share a sequence between the source table and new table, create a shared sequence (do not use <strong id="EN-US_TOPIC_0000001460561348__b164482944810">OWNED BY</strong>) and set a column in the source table to this sequence.</li><li id="EN-US_TOPIC_0000001460561348__li112431992510">You are not advised to set a column in the source table to the sequence specific to another table especially when the table is distributed in specific Node Groups, because doing so may result in <strong id="EN-US_TOPIC_0000001460561348__b579816143587">CREATE TABLE ... LIKE</strong> execution failures. In addition, doing so may cause the sequence to become invalid in the source sequence because the sequence will also be deleted from the source table when it is deleted from the table that the sequence is specific to. To share a sequence among multiple tables, you are advised to create a shared sequence for them.</li></ul>
</div></div>
</li><li id="EN-US_TOPIC_0000001460561348__l4af34b084f7c4b1a96c37516810dc04d"><strong id="EN-US_TOPIC_0000001460561348__a2761a7089649476bbf0299a61e9f23da">WITH ( { storage_parameter = value } [, ... ] )</strong><p id="EN-US_TOPIC_0000001460561348__ac10e4ce413a0489b927941d4d9e1e18e">Specifies an optional storage parameter for a table or an index.</p>
<div class="note" id="EN-US_TOPIC_0000001460561348__nb4e9ac710039431c818878c9ef231cb5"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="EN-US_TOPIC_0000001460561348__a3633deb081774802874582aa62fc0746">Using Numeric of any precision to define column, specifies precision p and scale s. When precision and scale are not specified, the input will be displayed.</p>
</div></div>
<p id="EN-US_TOPIC_0000001460561348__aa2fd5d776c8845a8ad24a34d286c09c7">The description of parameters is as follows:</p>
<ul id="EN-US_TOPIC_0000001460561348__u3170c562e94a492897636fbfcbcfb2b5"><li id="EN-US_TOPIC_0000001460561348__l24d1225dcddd4f08b059e91853936932">FILLFACTOR<p id="EN-US_TOPIC_0000001460561348__ac011eb472f2141c6834cf6a606c3d299"><a name="EN-US_TOPIC_0000001460561348__l24d1225dcddd4f08b059e91853936932"></a><a name="l24d1225dcddd4f08b059e91853936932"></a>The fillfactor of a table is a percentage between 10 and 100. 100 (complete packing) is the default value. When a smaller fillfactor is specified, <strong id="EN-US_TOPIC_0000001460561348__b2270294916957">INSERT</strong> operations pack table pages only to the indicated percentage. The remaining space on each page is reserved for updating rows on that page. This gives <strong id="EN-US_TOPIC_0000001460561348__b299995416957">UPDATE</strong> a chance to place the updated copy of a row on the same page, which is more efficient than placing it on a different page. For a table whose records are never updated, setting the fillfactor to 100 (complete packing) is the appropriate choice, but in heavily updated tables smaller fillfactors are appropriate. The parameter has no meaning for columnstore tables.</p>
<p id="EN-US_TOPIC_0000001460561348__a0a5934b8d9434bf489d67f14cc27868b">Value range: 10 to 100</p>
</li><li id="EN-US_TOPIC_0000001460561348__le578deaf72b64b2fba7c1ae284e30b15">ORIENTATION<p id="EN-US_TOPIC_0000001460561348__a255bea141fad4ab3bd9d37c304c3a315"><a name="EN-US_TOPIC_0000001460561348__le578deaf72b64b2fba7c1ae284e30b15"></a><a name="le578deaf72b64b2fba7c1ae284e30b15"></a>Specifies the storage mode (row-store, column-store) for table data. This parameter cannot be modified once it is set.</p>
<p id="EN-US_TOPIC_0000001460561348__a070516800fa944bfae754bd3a5e3ccc7">Valid value:</p>
<ul id="EN-US_TOPIC_0000001460561348__ua9832dec6c604f25a00e3a52cac1d7d9"><li id="EN-US_TOPIC_0000001460561348__l2c49a5929a3b47a59a24f5c8baaca843"><strong id="EN-US_TOPIC_0000001460561348__b842352706221833">ROW</strong> indicates that table data is stored in rows.<p id="EN-US_TOPIC_0000001460561348__a66f4ae52ca0d4df3aff0f52ed23f6c81"><strong id="EN-US_TOPIC_0000001460561348__b842352706221853">ROW</strong> applies to OLTP service, which has many interactive transactions. An interaction involves many columns in the table. Using ROW can improve the efficiency.</p>
</li><li id="EN-US_TOPIC_0000001460561348__le28dcda0112348209ae14aa1b9a6a2ca"><strong id="EN-US_TOPIC_0000001460561348__b0608142420116">COLUMN</strong> indicates that the data is stored in columns.<p id="EN-US_TOPIC_0000001460561348__a28561aef4f9f4a91897abd56177c3de9"><strong id="EN-US_TOPIC_0000001460561348__b9230165919119">COLUMN</strong> applies to the data warehouse service, which has a large amount of aggregation computing, and involves a few column operations.</p>
</li></ul>
<p id="EN-US_TOPIC_0000001460561348__p166641755203517">Default value: <strong id="EN-US_TOPIC_0000001460561348__b5217113974615">ROW</strong> (row-store)</p>
<div class="note" id="EN-US_TOPIC_0000001460561348__note967531791515"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="EN-US_TOPIC_0000001460561348__p6480151911261">In cluster 8.1.3 and later versions, the GUC parameter <strong id="EN-US_TOPIC_0000001460561348__b758836997024">default_orientation</strong> (default value: <strong id="EN-US_TOPIC_0000001460561348__b10322006477024">row</strong>) is added. If the storage mode is not specified when a table is created, by default, the table is created based on the value of the parameter (row, column, column enabledelta).</p>
</div></div>
</li><li id="EN-US_TOPIC_0000001460561348__l770ea1d44c9f44bf8d17c8cb0a26bac6">COMPRESSION<p id="EN-US_TOPIC_0000001460561348__ac2dfb496dc8e4ce6a291fd888995f6e9"><a name="EN-US_TOPIC_0000001460561348__l770ea1d44c9f44bf8d17c8cb0a26bac6"></a><a name="l770ea1d44c9f44bf8d17c8cb0a26bac6"></a>Specifies the compression level of the table data. It determines the compression ratio and time. Generally, the higher the level of compression, the higher the ratio, the longer the time, and the lower the level of compression, the lower the ratio, the shorter the time. The actual compression ratio depends on the distribution characteristics of loading table data.</p>
<p id="EN-US_TOPIC_0000001460561348__ac519dc54e9f84c90b3c8cd208f43c883">Valid value:</p>
<div class="p" id="EN-US_TOPIC_0000001460561348__p76411319118">The valid values for column-store tables are <strong id="EN-US_TOPIC_0000001460561348__b11212143744315">YES</strong>/<strong id="EN-US_TOPIC_0000001460561348__b17618738204312">NO</strong> and <strong id="EN-US_TOPIC_0000001460561348__b103841140134312">LOW</strong>/<strong id="EN-US_TOPIC_0000001460561348__b1144654317433">MIDDLE</strong>/<strong id="EN-US_TOPIC_0000001460561348__b1846219458430">HIGH</strong>, and the default is <strong id="EN-US_TOPIC_0000001460561348__b842352706112332">LOW</strong>. If this parameter is set to <strong id="EN-US_TOPIC_0000001460561348__b31713876210338">YES</strong>, the compression level is <strong id="EN-US_TOPIC_0000001460561348__b83171293010338">LOW</strong> by default.<div class="note" id="EN-US_TOPIC_0000001460561348__note141418320435"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><ul id="EN-US_TOPIC_0000001460561348__ul82263435309"><li id="EN-US_TOPIC_0000001460561348__li39874611479">Currently, compression is unavailable for row-store tables.</li><li id="EN-US_TOPIC_0000001460561348__li19912184182412">To determine the size of a new GaussDB(DWS) cluster, consider the size of ORC data compressed and migrated to column-store tables in GaussDB(DWS). If the compression level is low, the size of a copy is about 1.5 to 2 times that of ORC. If the compression level is high, the size of a copy is basically the same as that of ORC.</li><li id="EN-US_TOPIC_0000001460561348__li13912154172415">The middle compression of column-stores uses dictionary compression. For data not suitable for dictionary compression, the file size after middle compression may be greater than that of after low compression.</li></ul>
</div></div>
</div>
<p id="EN-US_TOPIC_0000001460561348__p2810714202814"><span id="EN-US_TOPIC_0000001460561348__text621906510">GaussDB(DWS)</span> provides the following compression algorithms:</p>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="EN-US_TOPIC_0000001460561348__table340453215226" frame="border" border="1" rules="all"><caption><b>Table 1 </b>Compression algorithms for column-based storage</caption><thead align="left"><tr id="EN-US_TOPIC_0000001460561348__row7405123242212"><th align="left" class="cellrowborder" valign="top" width="20%" id="mcps1.3.4.2.11.5.3.5.2.5.1.1"><p id="EN-US_TOPIC_0000001460561348__p19405232182210">COMPRESSION</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="26%" id="mcps1.3.4.2.11.5.3.5.2.5.1.2"><p id="EN-US_TOPIC_0000001460561348__p740553213223">NUMERIC</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="26%" id="mcps1.3.4.2.11.5.3.5.2.5.1.3"><p id="EN-US_TOPIC_0000001460561348__p9405232172213">STRING</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="28.000000000000004%" id="mcps1.3.4.2.11.5.3.5.2.5.1.4"><p id="EN-US_TOPIC_0000001460561348__p640533242216">INT</p>
</th>
</tr>
</thead>
<tbody><tr id="EN-US_TOPIC_0000001460561348__row7406332162215"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.4.2.11.5.3.5.2.5.1.1 "><p id="EN-US_TOPIC_0000001460561348__p24060329223">LOW</p>
</td>
<td class="cellrowborder" valign="top" width="26%" headers="mcps1.3.4.2.11.5.3.5.2.5.1.2 "><p id="EN-US_TOPIC_0000001460561348__p84061732142214">Delta compression + RLE compression</p>
</td>
<td class="cellrowborder" valign="top" width="26%" headers="mcps1.3.4.2.11.5.3.5.2.5.1.3 "><p id="EN-US_TOPIC_0000001460561348__p194066323225">LZ4 compression</p>
</td>
<td class="cellrowborder" valign="top" width="28.000000000000004%" headers="mcps1.3.4.2.11.5.3.5.2.5.1.4 "><p id="EN-US_TOPIC_0000001460561348__p740614326221">Delta compression (RLE is optional.)</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001460561348__row11406133217228"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.4.2.11.5.3.5.2.5.1.1 "><p id="EN-US_TOPIC_0000001460561348__p3406103242218">MIDDLE</p>
</td>
<td class="cellrowborder" valign="top" width="26%" headers="mcps1.3.4.2.11.5.3.5.2.5.1.2 "><p id="EN-US_TOPIC_0000001460561348__p1140683219229">Delta compression + RLE compression + LZ4 compression</p>
</td>
<td class="cellrowborder" valign="top" width="26%" headers="mcps1.3.4.2.11.5.3.5.2.5.1.3 "><p id="EN-US_TOPIC_0000001460561348__p640623292214">dict compression or LZ4 compression</p>
</td>
<td class="cellrowborder" valign="top" width="28.000000000000004%" headers="mcps1.3.4.2.11.5.3.5.2.5.1.4 "><p id="EN-US_TOPIC_0000001460561348__p1340653292210">Delta compression or LZ4 compression (RLE is optional)</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001460561348__row84061932202218"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.4.2.11.5.3.5.2.5.1.1 "><p id="EN-US_TOPIC_0000001460561348__p340673252211">HIGH</p>
</td>
<td class="cellrowborder" valign="top" width="26%" headers="mcps1.3.4.2.11.5.3.5.2.5.1.2 "><p id="EN-US_TOPIC_0000001460561348__p11407103214224">Delta compression + RLE compression + zlib compression</p>
</td>
<td class="cellrowborder" valign="top" width="26%" headers="mcps1.3.4.2.11.5.3.5.2.5.1.3 "><p id="EN-US_TOPIC_0000001460561348__p164071532152219">dict compression or zlib compression</p>
</td>
<td class="cellrowborder" valign="top" width="28.000000000000004%" headers="mcps1.3.4.2.11.5.3.5.2.5.1.4 "><p id="EN-US_TOPIC_0000001460561348__p340717323228">Delta compression or zlib compression (RLE is optional)</p>
</td>
</tr>
</tbody>
</table>
</div>
</li><li id="EN-US_TOPIC_0000001460561348__l677fdcd156914cc8bdaaa4713c333b34">COMPRESSLEVEL<p id="EN-US_TOPIC_0000001460561348__a58c1b12b31464cfba45d9ce40aa51f4e"><a name="EN-US_TOPIC_0000001460561348__l677fdcd156914cc8bdaaa4713c333b34"></a><a name="l677fdcd156914cc8bdaaa4713c333b34"></a>Specifies the compression level of the table data. It determines the compression ratio and time. This divides a compression level into sublevels, providing you with more choices for compression rate and duration. As the value becomes greater, the compression rate becomes higher and duration longer at the same compression level. The parameter is only valid for column-store tables.</p>
<p id="EN-US_TOPIC_0000001460561348__p7999121210374">Value range: 03.</p>
<p id="EN-US_TOPIC_0000001460561348__a50ebabc106f1448c95d6b1c810e1aa48">Default value: <strong id="EN-US_TOPIC_0000001460561348__b17938264857024">0</strong></p>
</li><li id="EN-US_TOPIC_0000001460561348__en-us_topic_0000001254211977_li11305165613216">TTL<p id="EN-US_TOPIC_0000001460561348__en-us_topic_0000001254211977_p143051956193219"><a name="EN-US_TOPIC_0000001460561348__en-us_topic_0000001254211977_li11305165613216"></a><a name="en-us_topic_0000001254211977_li11305165613216"></a>Schedules the partition deletion tasks in a partitioned table. By default, no partition deletion task is created.</p>
<p id="EN-US_TOPIC_0000001460561348__en-us_topic_0000001254211977_p430514567322">Value range: 1 hour100 years</p>
</li><li id="EN-US_TOPIC_0000001460561348__en-us_topic_0000001254211977_li1562417123317">PERIOD<p id="EN-US_TOPIC_0000001460561348__en-us_topic_0000001254211977_p1256251719339"><a name="EN-US_TOPIC_0000001460561348__en-us_topic_0000001254211977_li1562417123317"></a><a name="en-us_topic_0000001254211977_li1562417123317"></a>Schedules the partition creation tasks in a partitioned table. If <strong id="EN-US_TOPIC_0000001460561348__b38021840114810">TTL</strong> has been configured, <strong id="EN-US_TOPIC_0000001460561348__b180224094817">PERIOD</strong> cannot be greater than <strong id="EN-US_TOPIC_0000001460561348__b1680319405481">TTL</strong>.</p>
<p id="EN-US_TOPIC_0000001460561348__p14517737792">Value range: 1 hour100 years</p>
<p id="EN-US_TOPIC_0000001460561348__en-us_topic_0000001254211977_p17562017193310">Default value: 1 day</p>
</li><li id="EN-US_TOPIC_0000001460561348__lff6a2288b8ec472993acbcf2b2d7c984">MAX_BATCHROW<p id="EN-US_TOPIC_0000001460561348__a55c284d6c0c843e0861506326473d715"><a name="EN-US_TOPIC_0000001460561348__lff6a2288b8ec472993acbcf2b2d7c984"></a><a name="lff6a2288b8ec472993acbcf2b2d7c984"></a>Specifies the maximum of a storage unit during data loading process. The parameter is only valid for column-store tables.</p>
<p id="EN-US_TOPIC_0000001460561348__p59361644122913">Value range: 10000 to 60000</p>
<p id="EN-US_TOPIC_0000001460561348__af17457566b404c3aa62bfef662c9fba3">Default value: <strong id="EN-US_TOPIC_0000001460561348__b113811412210">60000</strong></p>
</li><li id="EN-US_TOPIC_0000001460561348__l09d7b9048bcd4612a7e3529d8597419f">PARTIAL_CLUSTER_ROWS<p id="EN-US_TOPIC_0000001460561348__ad566fbb5176e467cbcaafdd158c25afc"><a name="EN-US_TOPIC_0000001460561348__l09d7b9048bcd4612a7e3529d8597419f"></a><a name="l09d7b9048bcd4612a7e3529d8597419f"></a>Specifies the number of records to be partial cluster stored during data loading process. The parameter is only valid for column-store tables.</p>
<p id="EN-US_TOPIC_0000001460561348__a743957d47ee549909ca4d0ebc5fb5ed4">Value range: 600000 to 2147483647</p>
</li><li id="EN-US_TOPIC_0000001460561348__li2613194271216">enable_delta<p id="EN-US_TOPIC_0000001460561348__p1761394219122"><a name="EN-US_TOPIC_0000001460561348__li2613194271216"></a><a name="li2613194271216"></a>Specifies whether to enable delta tables in column-store tables. The parameter is only valid for column-store tables.</p>
<p id="EN-US_TOPIC_0000001460561348__p561354210126">Default value: <strong id="EN-US_TOPIC_0000001460561348__b18489181710210">off</strong></p>
</li><li id="EN-US_TOPIC_0000001460561348__li4236202164514">enable_hstore<p id="EN-US_TOPIC_0000001460561348__p22361025458"><a name="EN-US_TOPIC_0000001460561348__li4236202164514"></a><a name="li4236202164514"></a>Specifies whether an H-Store table will be created (based on column-store tables). The parameter is only valid for column-store tables. This parameter is supported by version 8.2.0.100 or later clusters.</p>
<p id="EN-US_TOPIC_0000001460561348__p13236520457">Default value: <strong id="EN-US_TOPIC_0000001460561348__b485850194">off</strong></p>
<div class="note" id="EN-US_TOPIC_0000001460561348__note1034095181611"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="EN-US_TOPIC_0000001460561348__p644992824620">If this parameter is enabled, the following GUC parameters must be set to ensure that H-Store tables are cleared.</p>
<p id="EN-US_TOPIC_0000001460561348__p193173119500">autovacuum=on, autovacuum_max_workers=6, autovacuum_max_workers_hstore=3.</p>
</div></div>
</li><li id="EN-US_TOPIC_0000001460561348__li1731172013545">enable_disaster_cstore<p id="EN-US_TOPIC_0000001460561348__p431132017546"><a name="EN-US_TOPIC_0000001460561348__li1731172013545"></a><a name="li1731172013545"></a>Specifies whether fine-grained DR will be enabled for column-store tables. This parameter only takes effect on column-store tables whose COLVERSION is 2.0 and cannot be set to <strong id="EN-US_TOPIC_0000001460561348__b879485915243">true</strong> if <strong id="EN-US_TOPIC_0000001460561348__b779463102518">enable_hstore</strong> is <strong id="EN-US_TOPIC_0000001460561348__b579885122516">true</strong>. This parameter is supported by version 8.2.0.100 or later clusters.</p>
</li><li id="EN-US_TOPIC_0000001460561348__li1083514691112">fine_disaster_table_role<p id="EN-US_TOPIC_0000001460561348__p11451410308"><a name="EN-US_TOPIC_0000001460561348__li1083514691112"></a><a name="li1083514691112"></a>This parameter has been discarded in version 8.2.1 and is reserved for compatibility with earlier versions. This parameter is invalid in the current version.</p>
<p id="EN-US_TOPIC_0000001460561348__p13835346191116">Specifies whether the fine-grained DR table will be set as a primary or secondary table. This parameter can be <strong id="EN-US_TOPIC_0000001460561348__b144388562914">true</strong> only when the <strong id="EN-US_TOPIC_0000001460561348__b10620101392818">enable_disaster_cstore</strong> parameter has been set to <strong id="EN-US_TOPIC_0000001460561348__b17925112752818">true</strong>.</p>
<p id="EN-US_TOPIC_0000001460561348__p1791385616136">Valid value:</p>
<ul id="EN-US_TOPIC_0000001460561348__ul149131756111310"><li id="EN-US_TOPIC_0000001460561348__li119131563136"><strong id="EN-US_TOPIC_0000001460561348__b147841420292">primary</strong>: Specifies the primary fine-grained DR table.</li><li id="EN-US_TOPIC_0000001460561348__li891375691315"><strong id="EN-US_TOPIC_0000001460561348__b452891792911">standby</strong>: Specifies the standby fine-grained DR table.</li></ul>
</li><li id="EN-US_TOPIC_0000001460561348__l70caac449c624b2aafb1efe4b6ba69f7">DELTAROW_THRESHOLD<p id="EN-US_TOPIC_0000001460561348__a405e51516cf94d89b2ecfe461f1cdfd8"><a name="EN-US_TOPIC_0000001460561348__l70caac449c624b2aafb1efe4b6ba69f7"></a><a name="l70caac449c624b2aafb1efe4b6ba69f7"></a>Specifies the upper limit of to-be-imported rows for triggering the data import to a delta table when data is to be imported to a column-store table. This parameter takes effect only if the <strong id="EN-US_TOPIC_0000001460561348__b83454182414">enable_delta</strong> table parameter is set to <strong id="EN-US_TOPIC_0000001460561348__b147114391302">on</strong>. The parameter is only valid for column-store tables.</p>
<p id="EN-US_TOPIC_0000001460561348__p121507813619">Value range: 0 to 60000</p>
<p id="EN-US_TOPIC_0000001460561348__aad22c617d71142a991d7fc027213e78c"><strong id="EN-US_TOPIC_0000001460561348__b11214174267025">Default value</strong>: <strong id="EN-US_TOPIC_0000001460561348__b17621666157025">6000</strong></p>
</li><li id="EN-US_TOPIC_0000001460561348__li650019179418">COLVERSION<p id="EN-US_TOPIC_0000001460561348__p35006179418"><a name="EN-US_TOPIC_0000001460561348__li650019179418"></a><a name="li650019179418"></a>Specifies the version of the column-store format. You can switch between different storage formats.</p>
<p id="EN-US_TOPIC_0000001460561348__p1850016171446">Valid value:</p>
<p id="EN-US_TOPIC_0000001460561348__p1050014175413"><strong id="EN-US_TOPIC_0000001460561348__b20944591851">1.0</strong>: Each column in a column-store table is stored in a separate file. The file name is <strong id="EN-US_TOPIC_0000001460561348__b198832225512">relfilenode.C1.0</strong>, <strong id="EN-US_TOPIC_0000001460561348__b66763253515">relfilenode.C2.0</strong>, <strong id="EN-US_TOPIC_0000001460561348__b1787492815518">relfilenode.C3.0</strong>, or similar.</p>
<p id="EN-US_TOPIC_0000001460561348__p1250012171411"><strong id="EN-US_TOPIC_0000001460561348__b10683155883413">2.0</strong>: All columns of a column-store table are combined and stored in a file. The file is named <strong id="EN-US_TOPIC_0000001460561348__b768315588341">relfilenode.C1.0</strong>.</p>
<p id="EN-US_TOPIC_0000001460561348__p19500917545">Default value: <strong id="EN-US_TOPIC_0000001460561348__b1189815251612">2.0</strong></p>
<p id="EN-US_TOPIC_0000001460561348__p135079255718">The value of <strong id="EN-US_TOPIC_0000001460561348__b1612615774010">COLVERSION</strong> can only be set to <strong id="EN-US_TOPIC_0000001460561348__b550718171406">2.0</strong> for OBS multi-temperature tables.</p>
<div class="note" id="EN-US_TOPIC_0000001460561348__note57078250414"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><ul id="EN-US_TOPIC_0000001460561348__ul11967181133"><li id="EN-US_TOPIC_0000001460561348__li21961418181314">For clusters of version 8.1.0, the default value of this parameter is <strong id="EN-US_TOPIC_0000001460561348__b72114127025">1.0</strong>. For clusters of version 8.1.1 or later, the default value of this parameter is <strong id="EN-US_TOPIC_0000001460561348__b3301686927025">2.0</strong>. If the cluster version is upgraded from 8.1.0 to 8.1.1 or later, the default value of this parameter changes from <strong id="EN-US_TOPIC_0000001460561348__b7176309217025">1.0</strong> to <strong id="EN-US_TOPIC_0000001460561348__b19271558107025">2.0</strong>.</li><li id="EN-US_TOPIC_0000001460561348__li3196918201311">When creating a column-store table, set <strong id="EN-US_TOPIC_0000001460561348__b6046088717025">COLVERSION</strong> to <strong id="EN-US_TOPIC_0000001460561348__b21307955457025">2.0</strong>. Compared with the <strong id="EN-US_TOPIC_0000001460561348__b6757197257025">1.0</strong> storage format, the performance is significantly improved:<ul id="EN-US_TOPIC_0000001460561348__ul16703554185611"><li id="EN-US_TOPIC_0000001460561348__li770375415569">The time required for creating a column-store wide table is significantly reduced.</li><li id="EN-US_TOPIC_0000001460561348__li1470335475617">In the Roach data backup scenario, the backup time is significantly reduced.</li><li id="EN-US_TOPIC_0000001460561348__li8703155410562">The build and catch up time is greatly reduced.</li><li id="EN-US_TOPIC_0000001460561348__li870335419560">The occupied disk space decreases significantly.</li></ul>
</li></ul>
</div></div>
</li><li id="EN-US_TOPIC_0000001460561348__li280884617368">analyze_mode<p id="EN-US_TOPIC_0000001460561348__p10808184611361"><a name="EN-US_TOPIC_0000001460561348__li280884617368"></a><a name="li280884617368"></a>Specifies the mode of table-level auto-analyze.</p>
<p id="EN-US_TOPIC_0000001460561348__p11808146113620">Valid value:</p>
<ul id="EN-US_TOPIC_0000001460561348__ul124501408445"><li id="EN-US_TOPIC_0000001460561348__li1945016013448"><strong id="EN-US_TOPIC_0000001460561348__b14787612115718">frozen</strong>: disables all <strong id="EN-US_TOPIC_0000001460561348__b1577911511707">ANALYZE</strong> operations (dynamic sampling can still be triggered when no statistics are collected).</li><li id="EN-US_TOPIC_0000001460561348__li321102214441"><strong id="EN-US_TOPIC_0000001460561348__b5784125945919">backend</strong>: allows only <strong id="EN-US_TOPIC_0000001460561348__b1741133817716">ANALYZE</strong> triggered by <strong id="EN-US_TOPIC_0000001460561348__b65241819987">AUTOVACUUM</strong> polling.</li><li id="EN-US_TOPIC_0000001460561348__li834013241448"><strong id="EN-US_TOPIC_0000001460561348__b1272611241680">runtime</strong>: allows only runtime <strong id="EN-US_TOPIC_0000001460561348__b1258717416817">ANALYZE</strong> triggered by the optimizer.</li><li id="EN-US_TOPIC_0000001460561348__li141931812164419"><strong id="EN-US_TOPIC_0000001460561348__b3549195112811">all</strong>: Both backend and runtime <strong id="EN-US_TOPIC_0000001460561348__b165111130290">AUTO-ANALYZE</strong> can be triggered.</li></ul>
<p id="EN-US_TOPIC_0000001460561348__p1172410511374">Default value: <strong id="EN-US_TOPIC_0000001460561348__b4819996567025">all</strong></p>
</li><li id="EN-US_TOPIC_0000001460561348__li32608317479">SKIP_FPI_HINT<p id="EN-US_TOPIC_0000001460561348__p185568515461"><a name="EN-US_TOPIC_0000001460561348__li32608317479"></a><a name="li32608317479"></a>Indicates whether to skip the hint bits operation when the full-page writes (FPW) log needs to be written during sequential scanning.</p>
<div class="p" id="EN-US_TOPIC_0000001460561348__p3172164012188">Default value: <strong id="EN-US_TOPIC_0000001460561348__b94410361223">false</strong><div class="note" id="EN-US_TOPIC_0000001460561348__note177211636121818"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="EN-US_TOPIC_0000001460561348__p1721193631819">If <strong id="EN-US_TOPIC_0000001460561348__b1792110392228">SKIP_FPI_HINT</strong> is set to <strong id="EN-US_TOPIC_0000001460561348__b15922173962217">true</strong> and the checkpoint operation is performed on a table, no Xlog will be generated when the table is sequentially scanned. This applies to intermediate tables that are queried less frequently, reducing the size of Xlogs and improving query performance.</p>
</div></div>
</div>
</li><li id="EN-US_TOPIC_0000001460561348__li19341172911552">enable_column_autovacuum_garbage<p id="EN-US_TOPIC_0000001460561348__p13709132310477"><a name="EN-US_TOPIC_0000001460561348__li19341172911552"></a><a name="li19341172911552"></a>Determines whether to enable CU rewriting logic for column-store tables using AUTOVACUUM. This parameter is supported only by clusters of version 8.2.1.100 or later.</p>
<p id="EN-US_TOPIC_0000001460561348__p1089782517476">There is a low probability that an error is reported when lightweight UPDATE and AUTOVACUUM are executed concurrently. You can set the table-level parameter to <strong id="EN-US_TOPIC_0000001460561348__b780116157393">off</strong> to avoid this problem.</p>
<p id="EN-US_TOPIC_0000001460561348__p16341202955520">Default value: <strong id="EN-US_TOPIC_0000001460561348__b1819285281103716">true</strong></p>
</li></ul>
</li><li id="EN-US_TOPIC_0000001460561348__l8778c2de5deb44879d6adc63997b804b"><strong id="EN-US_TOPIC_0000001460561348__a4e0ed1cea7a94fb38f15fd9a17dde22f">ON COMMIT { PRESERVE ROWS | DELETE ROWS }</strong><p id="EN-US_TOPIC_0000001460561348__aa82d8f22c5ce4ed9b7aec0e5a647a24c"><strong id="EN-US_TOPIC_0000001460561348__b84235270622221">ON COMMIT</strong> determines what to do when you commit a temporary table creation operation. </p>
<ul id="EN-US_TOPIC_0000001460561348__uf04036b9aecb4e38a9a87afa68f8f826"><li id="EN-US_TOPIC_0000001460561348__lec0de098db28479b9d349b28aa654574"><strong id="EN-US_TOPIC_0000001460561348__b84235270692117">PRESERVE ROWS</strong> (Default): No special action is taken at the ends of transactions. The temporary table and its table data are unchanged.</li><li id="EN-US_TOPIC_0000001460561348__lb2a32fb7def94ffb85f1a4b4a8c7cbe5"><strong id="EN-US_TOPIC_0000001460561348__b84235270692128">DELETE ROWS</strong>: All rows in the temporary table will be deleted at the end of each transaction block.</li></ul>
</li><li id="EN-US_TOPIC_0000001460561348__l452d636623504de999b1861722855da0"><strong id="EN-US_TOPIC_0000001460561348__a0ddcb239173b4ef088d9bb07443df05f">COMPRESS | NOCOMPRESS</strong><p id="EN-US_TOPIC_0000001460561348__aba870fc5cf4b409a8a48c7d2976d16b9">If you specify <strong id="EN-US_TOPIC_0000001460561348__b84235270685040">COMPRESS</strong> in the <strong id="EN-US_TOPIC_0000001460561348__b842352706222332">CREATE TABLE</strong> statement, the compression feature is triggered in the case of a bulk <strong id="EN-US_TOPIC_0000001460561348__b522675911783">INSERT</strong> operation. If this feature is enabled, a scan is performed for all tuple data within the page to generate a dictionary and then the tuple data is compressed and stored. If <strong id="EN-US_TOPIC_0000001460561348__b6462771783">NOCOMPRESS</strong> is specified, the table is not compressed.</p>
<p id="EN-US_TOPIC_0000001460561348__ab61852391992405c930b2e42ca07d02a">Default value: <strong id="EN-US_TOPIC_0000001460561348__b842352706163420">NOCOMPRESS</strong>, tuple data is not compressed before storage.</p>
</li><li id="EN-US_TOPIC_0000001460561348__l1b1100015510493f95d6ef3eb261ea6f"><strong id="EN-US_TOPIC_0000001460561348__a44ff5ec06a60485dbe758a6c55a6d94f">DISTRIBUTE BY</strong><p id="EN-US_TOPIC_0000001460561348__a19cb82952a8146468059d792e8610de8">Specifies how the table is distributed or replicated between DNs.</p>
<p id="EN-US_TOPIC_0000001460561348__aab03e894b1604b919ed18088065dbf8f">Valid value:</p>
<ul id="EN-US_TOPIC_0000001460561348__u1d259cf19d074fda9764568b2a5d839d"><li id="EN-US_TOPIC_0000001460561348__l30d142a45e884e5cab2030dbd866588d"><strong id="EN-US_TOPIC_0000001460561348__b629718321047">REPLICATION</strong>: Each row in the table exists on all DNs, that is, each DN has complete table data.</li><li id="EN-US_TOPIC_0000001460561348__li108823195568"><strong id="EN-US_TOPIC_0000001460561348__b1718417214254">ROUNDROBIN</strong>: Each row in the table is sent to each DN in turn. Therefore, data is evenly distributed on each DN. This value is supported only in 8.1.2 or later.</li><li id="EN-US_TOPIC_0000001460561348__l5371e22afc33433486d5e013fc7c916a"><strong id="EN-US_TOPIC_0000001460561348__b729810325413">HASH (column_name)</strong>: Each row of the table will be placed into all the DNs based on the hash value of the specified column.<div class="note" id="EN-US_TOPIC_0000001460561348__n0b3a96f26491458aa9c897d57966df8c"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><ul id="EN-US_TOPIC_0000001460561348__uf95d23edb74a44a6aa030f93ccdbeb6c"><li id="EN-US_TOPIC_0000001460561348__l0e39717ab5dd4af592c7c669ab565dac">When <strong id="EN-US_TOPIC_0000001460561348__b730893217410">DISTRIBUTE BY HASH (column_name)</strong> is specified, the primary key and its unique index must contain the <strong id="EN-US_TOPIC_0000001460561348__b123084322412">column_name</strong> column.</li><li id="EN-US_TOPIC_0000001460561348__l31a5501f79dd4645be7e6ce15068a67a">When <strong id="EN-US_TOPIC_0000001460561348__b43100327418">DISTRIBUTE BY HASH (column_name)</strong> in a referenced table is specified, the foreign key of the reference table must contain the <strong id="EN-US_TOPIC_0000001460561348__b203101232244">column_name</strong> column.</li><li id="EN-US_TOPIC_0000001460561348__li0412013539">If <strong id="EN-US_TOPIC_0000001460561348__b8390192318714">TO GROUP</strong> is set to a replication table node group (supported in 8.1.2 or later), <strong id="EN-US_TOPIC_0000001460561348__b105251437479">DISTRIBUTE BY</strong> must be set to <strong id="EN-US_TOPIC_0000001460561348__b81275411476">REPLICATION</strong>. If <strong id="EN-US_TOPIC_0000001460561348__b10374651877">DISTRIBUTE BY</strong> is not specified, the created table is automatically set as a replication table.</li><li id="EN-US_TOPIC_0000001460561348__li6887450733">The hybrid data warehouse (standalone) has only one DN. Therefore, the distribution rule is ignored and cannot be modified.</li></ul>
</div></div>
</li></ul>
<div class="p" id="EN-US_TOPIC_0000001460561348__p1251615105171">Default value: determined by the GUC parameter <strong id="EN-US_TOPIC_0000001460561348__b011716451285">default_distribution_mode</strong><ul id="EN-US_TOPIC_0000001460561348__ul878364963015"><li id="EN-US_TOPIC_0000001460561348__li14783249163014">When <strong id="EN-US_TOPIC_0000001460561348__b481114201399">default_distribution_mode</strong> is set to <strong id="EN-US_TOPIC_0000001460561348__b161741329198">roundrobin</strong>, the default value of <strong id="EN-US_TOPIC_0000001460561348__b1133003416912">DISTRIBUTE BY</strong> is selected according to the following rules:<ol id="EN-US_TOPIC_0000001460561348__ol137381934837"><li id="EN-US_TOPIC_0000001460561348__li87381341531">If the primary key or unique constraint is included during table creation, hash distribution is selected. The distribution column is the column corresponding to the primary key or unique constraint.</li><li id="EN-US_TOPIC_0000001460561348__li0741558414">If the primary key or unique constraint is not included during table creation, round-robin distribution is selected.</li></ol>
</li><li id="EN-US_TOPIC_0000001460561348__li1645915396371">When <strong id="EN-US_TOPIC_0000001460561348__b46060081120">default_distribution_mode</strong> is set to <strong id="EN-US_TOPIC_0000001460561348__b56071109117">hash</strong>, the default value of <strong id="EN-US_TOPIC_0000001460561348__b560719013112">DISTRIBUTE BY</strong> is selected according to the following rules:<ol id="EN-US_TOPIC_0000001460561348__ol115828818381"><li id="EN-US_TOPIC_0000001460561348__li38741447517">If the primary key or unique constraint is included during table creation, hash distribution is selected. The distribution column is the column corresponding to the primary key or unique constraint.</li><li id="EN-US_TOPIC_0000001460561348__li990712591559">If the primary key or unique constraint is not included during table creation but there are columns whose data types can be used as distribution columns, hash distribution is selected. The distribution column is the first column whose data type can be used as a distribution column.</li><li id="EN-US_TOPIC_0000001460561348__li462574677">If the primary key or unique constraint is not included during table creation and no column whose data type can be used as a distribution column exists, round-robin distribution is selected.</li></ol>
</li></ul>
</div>
<div class="p" id="EN-US_TOPIC_0000001460561348__p613875615407">The following data types can be used as distribution columns:<ul id="EN-US_TOPIC_0000001460561348__ul8929105634111"><li id="EN-US_TOPIC_0000001460561348__li18929256194113">Integer types: <strong id="EN-US_TOPIC_0000001460561348__b10277105577">TINYINT</strong>, <strong id="EN-US_TOPIC_0000001460561348__b15277180185710">SMALLINT</strong>, <strong id="EN-US_TOPIC_0000001460561348__b122776020577">INT</strong>, <strong id="EN-US_TOPIC_0000001460561348__b1027811035720">BIGINT</strong>, and <strong id="EN-US_TOPIC_0000001460561348__b6278508578">NUMERIC/DECIMAL</strong></li><li id="EN-US_TOPIC_0000001460561348__li148954319420">Character types: <strong id="EN-US_TOPIC_0000001460561348__b139251435713">CHAR</strong>, <strong id="EN-US_TOPIC_0000001460561348__b12399101418571">BPCHAR</strong>, <strong id="EN-US_TOPIC_0000001460561348__b13399514135715">VARCHAR</strong>, <strong id="EN-US_TOPIC_0000001460561348__b640018143576">VARCHAR2</strong>, <strong id="EN-US_TOPIC_0000001460561348__b540061425713">NVARCHAR2</strong>, and <strong id="EN-US_TOPIC_0000001460561348__b17401141465716">TEXT</strong></li><li id="EN-US_TOPIC_0000001460561348__li14231162624317">Date/time types: <strong id="EN-US_TOPIC_0000001460561348__b180321819578">DATE</strong>, <strong id="EN-US_TOPIC_0000001460561348__b1581041810574">TIME</strong>, <strong id="EN-US_TOPIC_0000001460561348__b19810718155717">TIMETZ</strong>, <strong id="EN-US_TOPIC_0000001460561348__b8811121825714">TIMESTAMP</strong>, <strong id="EN-US_TOPIC_0000001460561348__b15811818165720">TIMESTAMPTZ</strong>, <strong id="EN-US_TOPIC_0000001460561348__b28111189574">INTERVAL</strong>, and <strong id="EN-US_TOPIC_0000001460561348__b148121018105711">SMALLDATETIME</strong></li></ul>
</div>
<div class="note" id="EN-US_TOPIC_0000001460561348__note11344125310577"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="EN-US_TOPIC_0000001460561348__p581911512589">When you create a table, the choices of distribution keys and partition keys have major impact on SQL query performance. Therefore, choosing proper distribution column and partition key with strategies.</p>
<ul id="EN-US_TOPIC_0000001460561348__ul165341241165920"><li id="EN-US_TOPIC_0000001460561348__li95391941195912">Selecting an Appropriate Distribution Column<div class="p" id="EN-US_TOPIC_0000001460561348__p355034125910"><a name="EN-US_TOPIC_0000001460561348__li95391941195912"></a><a name="li95391941195912"></a>In the data distributed table using Hash, an appropriate distributed array should be used to distribute and store data on multiple DNs evenly, preventing data skew (uneven data distribution across several DNs). Determine the proper distribution column based on the following principles:<ol id="EN-US_TOPIC_0000001460561348__ol196761081903"><li id="EN-US_TOPIC_0000001460561348__li86761881012">Determine whether data is skewed.<p class="litext" id="EN-US_TOPIC_0000001460561348__p1523150301"><a name="EN-US_TOPIC_0000001460561348__li86761881012"></a><a name="li86761881012"></a>Connect to the database and run the following statements to check the number of tuples on each DN: Replace <em id="EN-US_TOPIC_0000001460561348__i133101074917">tablename</em> with the actual name of the table to be analyzed.</p>
<pre class="screen" id="EN-US_TOPIC_0000001460561348__screen027304016"><span id="EN-US_TOPIC_0000001460561348__text338107017"></span><strong id="EN-US_TOPIC_0000001460561348__b34220020016">SELECT a.count,b.node_name FROM (SELECT count(*) AS count,xc_node_id FROM</strong> <em id="EN-US_TOPIC_0000001460561348__i14471501011">tablename</em> <strong id="EN-US_TOPIC_0000001460561348__b1753170505">GROUP BY xc_node_id) a, pgxc_node b WHERE a.xc_node_id=b.node_id ORDER BY a.count DESC;</strong></pre>
<p class="litext" id="EN-US_TOPIC_0000001460561348__p357130904">If tuple numbers vary greatly (several times or tenfold) in each DN, a data skew occurs. Change the data distribution key based on the following principles:</p>
</li><li id="EN-US_TOPIC_0000001460561348__li10727210113">Run the ALTER TABLE statement to adjust the distribution column. The rules for selecting a distribution column are as follows:<p id="EN-US_TOPIC_0000001460561348__p662318401315"><a name="EN-US_TOPIC_0000001460561348__li10727210113"></a><a name="li10727210113"></a>The column value of the distribution column should be discrete so that data can be evenly distributed on each DN. For example, you are advised to select the primary key of a table as the distribution column, and the ID card number as the distribution column in a personnel information table.</p>
<p id="EN-US_TOPIC_0000001460561348__p185933181230">With the above principles met, you can select join conditions as distribution keys so that join tasks can be pushed down to DNs, reducing the amount of data transferred between the DNs.</p>
</li><li id="EN-US_TOPIC_0000001460561348__li8774175432513">If a proper distribution column cannot be found to make data evenly distributed on each DN, you can use the <strong id="EN-US_TOPIC_0000001460561348__b15229102411414">REPLICATION</strong> or <strong id="EN-US_TOPIC_0000001460561348__b197737291445">ROUNDROBIN</strong> data distribution mode. The <strong id="EN-US_TOPIC_0000001460561348__b241513501645">REPLICATION</strong> data distribution mode stores complete data on each DN. Therefore, if a table is large and no proper distribution column can be found, the <strong id="EN-US_TOPIC_0000001460561348__b3691713455">ROUNDROBIN</strong> data distribution mode is recommended. The <strong id="EN-US_TOPIC_0000001460561348__b974110314510">ROUNDROBIN</strong> data distribution mode is supported in 8.1.2 or later.</li></ol>
</div>
</li><li id="EN-US_TOPIC_0000001460561348__li202881859343">Selecting appropriate partition keys<p id="EN-US_TOPIC_0000001460561348__p1731014598411"><a name="EN-US_TOPIC_0000001460561348__li202881859343"></a><a name="li202881859343"></a>In range partitioning, the table is partitioned into ranges defined by a key column or set of columns, with no overlap between the ranges of values assigned to different partitions. Each range has a dedicated partition for data storage.</p>
<p id="EN-US_TOPIC_0000001460561348__p3310145913413">Modify partition keys to make the query result stored in the same or least partitions (partition pruning). Obtaining consecutive I/O to improve the query performance.</p>
<p id="EN-US_TOPIC_0000001460561348__p3310859042">In actual services, time is used to filter query objects. Therefore, you can use time as a partition key, and change the key value based on the total data volume and single data query volume.</p>
</li></ul>
</div></div>
</li><li id="EN-US_TOPIC_0000001460561348__l952d2eb00a7a47bbaa7a6eab40966b69"><strong id="EN-US_TOPIC_0000001460561348__ae3a58cce858a4746a33e116011f28202">TO { GROUP groupname | NODE ( nodename [, ... ] ) }</strong><p id="EN-US_TOPIC_0000001460561348__a337dcd05ab1646748b2fc1e83c683295"><strong id="EN-US_TOPIC_0000001460561348__b741414264256">TO GROUP</strong> specifies the Node Group in which the table is created. Currently, it cannot be used for HDFS tables. <strong id="EN-US_TOPIC_0000001460561348__b842352706152947">TO NODE</strong> is used for internal scale-out tools.</p>
<p id="EN-US_TOPIC_0000001460561348__p62633616499">In logical cluster mode, if <strong id="EN-US_TOPIC_0000001460561348__b187570309219">TO GROUP</strong> is not specified, the table is created in the node group associated with the logical cluster user by default. If the user, such as the administrator or a common user, does not manage the logical cluster, by default the table is created in the first logical cluster, which is the logical cluster with the smallest <strong id="EN-US_TOPIC_0000001460561348__b622612279240">OID</strong> in <strong id="EN-US_TOPIC_0000001460561348__b72769533242">pgxc_group</strong>.</p>
<p id="EN-US_TOPIC_0000001460561348__p14384553125810">If the node group specified by <strong id="EN-US_TOPIC_0000001460561348__b053765920260">TO GROUP</strong> is a replication table node group, the table is created on all CNs and DNs, but the replication table data is distributed only on the DNs in the replication table node group.</p>
</li><li id="EN-US_TOPIC_0000001460561348__li568919439420"><strong id="EN-US_TOPIC_0000001460561348__b1661611920208">COMMENT [=] 'text'</strong><p id="EN-US_TOPIC_0000001460561348__p18695881579">The <strong id="EN-US_TOPIC_0000001460561348__b980816463277">COMMENT</strong> clause can specify table comments during table creation.</p>
</li><li id="EN-US_TOPIC_0000001460561348__l46786c0bcc524132bca8ab0b74952295"><strong id="EN-US_TOPIC_0000001460561348__a2081b217eae24189b7d455b5dc28db22">CONSTRAINT constraint_name</strong><p id="EN-US_TOPIC_0000001460561348__a86f0e2090d1349a292dde96cf61b880e">Specifies a name for a column or table constraint. The optional constraint clauses specify constraints that new or updated rows must satisfy for an insert or update operation to succeed.</p>
<p id="EN-US_TOPIC_0000001460561348__a9431027fb104402da3f0f1ce9b3fbd06">There are two ways to define constraints:</p>
<ul id="EN-US_TOPIC_0000001460561348__u6c8f9d65434b4228813d5f953d724bf7"><li id="EN-US_TOPIC_0000001460561348__l69f9da027d804911b4ce17b7bfb2b245">A column constraint is defined as part of a column definition, and it is bound to a particular column.</li><li id="EN-US_TOPIC_0000001460561348__l203273641c2d4afea1f00e912eb4bd2b">A table constraint is not bound to any particular columns but can apply to more than one column.</li></ul>
</li><li id="EN-US_TOPIC_0000001460561348__l30d2b1740e0148bfb5f07e997f46ef1c"><strong id="EN-US_TOPIC_0000001460561348__af9431c6ac92a4982a9fa901e53f6421b">NOT NULL</strong><p id="EN-US_TOPIC_0000001460561348__aa3bb437f01a843d7ad643e881e8554db">Indicates that the column is not allowed to contain <strong id="EN-US_TOPIC_0000001460561348__b87912263144857">NULL</strong> values.</p>
</li><li id="EN-US_TOPIC_0000001460561348__l88137e4d693a48a1a9c6289b75da0f30"><strong id="EN-US_TOPIC_0000001460561348__a0351f2a212154d13a48788f2cc7b8b3d">NULL</strong><p id="EN-US_TOPIC_0000001460561348__ae2ce887f32fc409996a3c45909a044ad">The column is allowed to contain <strong id="EN-US_TOPIC_0000001460561348__b842352706104637">NULL</strong> values. This is the default setting.</p>
<p id="EN-US_TOPIC_0000001460561348__ab08d5c26192b40b9ae89282ab63c646f">This clause is only provided for compatibility with non-standard SQL databases. You are advised not to use this clause.</p>
</li><li id="EN-US_TOPIC_0000001460561348__l62ab5db2e605425ba1475dd7010404e4"><strong id="EN-US_TOPIC_0000001460561348__a445d552fe9ae4d1ea848bf15afd0ac5e">CHECK ( expression )</strong><p id="EN-US_TOPIC_0000001460561348__ae4bd05430ba64a65b7e09cedd26cda6c">Specifies an expression producing a Boolean result which new or updated rows must satisfy for an insert or update operation to succeed. Expressions evaluating to <strong id="EN-US_TOPIC_0000001460561348__b84235270616515">TRUE</strong> or <strong id="EN-US_TOPIC_0000001460561348__b84235270616518">UNKNOWN</strong> succeed. If any row of an insert or update operation produces a FALSE result, an error exception is raised and the insert or update does not alter the database.</p>
<p id="EN-US_TOPIC_0000001460561348__a105edc449f4247a68685d1758be67111">A check constraint specified as a column constraint should reference only the column's values, while an expression appearing in a table constraint can reference multiple columns.</p>
<div class="note" id="EN-US_TOPIC_0000001460561348__note354734852610"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="EN-US_TOPIC_0000001460561348__p755211489268"><strong id="EN-US_TOPIC_0000001460561348__b14435145412214">&lt;&gt;NULL</strong> and <strong id="EN-US_TOPIC_0000001460561348__b1243720541026">!=NULL</strong> are invalid in an expression. Change them to <strong id="EN-US_TOPIC_0000001460561348__b144741956221">IS NOT NULL</strong>.</p>
</div></div>
</li><li id="EN-US_TOPIC_0000001460561348__l723523fcfe234f5d9744697a100a2d5b"><strong id="EN-US_TOPIC_0000001460561348__ae12044be71b94ca7bff594caad8bcc1b">DEFAULT default_expr</strong><p id="EN-US_TOPIC_0000001460561348__a7e8fa85ca0d24fec803141c818493a08">Assigns a default data value for a column. The value can be any variable-free expressions (Subqueries and cross-references to other columns in the current table are not allowed). The data type of the default expression must match the data type of the column.</p>
<p id="EN-US_TOPIC_0000001460561348__a136aabf04ffe43678229512a34a07ad2">The default expression will be used in any insert operation that does not specify a value for the column. If there is no default value for a column, then the default value is <strong id="EN-US_TOPIC_0000001460561348__b842352706104725">NULL</strong>.</p>
</li><li id="EN-US_TOPIC_0000001460561348__li11429032440"><strong id="EN-US_TOPIC_0000001460561348__b1058672261">ON UPDATE on_update_expr</strong><p id="EN-US_TOPIC_0000001460561348__p13682811588">The <strong id="EN-US_TOPIC_0000001460561348__b1180261813128">ON UPDATE</strong> clause specifies a timestamp function for a column. Ensure that the data type of the column for which the <strong id="EN-US_TOPIC_0000001460561348__b113713579237">ON UPDATE</strong> clause specifies a timestamp function is timestamp or timestamptz.</p>
<p id="EN-US_TOPIC_0000001460561348__p1725411481140">When an SQL statement containing the <strong id="EN-US_TOPIC_0000001460561348__b32620111016">UPDATE</strong> operation is executed, this column is automatically updated to the time specified by the timestamp function.</p>
<div class="note" id="EN-US_TOPIC_0000001460561348__note19776409141"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="EN-US_TOPIC_0000001460561348__p109771940101413">The <strong id="EN-US_TOPIC_0000001460561348__b475475811220">on_update_expr</strong> function supports only CURRENT_TIMESTAMP, CURRENT_TIME, CURRENT_DATE, LOCALTIME, LOCALTIMESTAMP.</p>
</div></div>
</li><li id="EN-US_TOPIC_0000001460561348__li9964195916187"><strong id="EN-US_TOPIC_0000001460561348__b17673421111913">COMMENT</strong><strong id="EN-US_TOPIC_0000001460561348__b8385201192010"> 'text'</strong><p id="EN-US_TOPIC_0000001460561348__p163036125201">The <strong id="EN-US_TOPIC_0000001460561348__b1831163372820">COMMENT</strong> clause can specify a comment for a column.</p>
</li><li id="EN-US_TOPIC_0000001460561348__l3947318658d747c0b403f7087fd9a662"><strong id="EN-US_TOPIC_0000001460561348__a403ac85ea7d44ff095eb59aaf8819053">UNIQUE [ NULLS [ NOT ] DISTINCT | NULLS IGNORE ] index_parameters</strong><p id="EN-US_TOPIC_0000001460561348__a470845db7cd14428bef79486a01d2295"><strong id="EN-US_TOPIC_0000001460561348__a8b6f1b6dbf8d4418a46a9bd65997d3ac">UNIQUE [ NULLS [ NOT ] DISTINCT | NULLS IGNORE ] ( column_name [, ... ] ) index_parameters</strong></p>
<p id="EN-US_TOPIC_0000001460561348__aecada5190e5f468eaff4d903bea0f476">Specifies that a group of one or more columns of a table can contain only unique values.</p>
<p id="EN-US_TOPIC_0000001460561348__p393220118438">The <strong id="EN-US_TOPIC_0000001460561348__b154815277468">[ NULLS [ NOT ] DISTINCT | NULLS IGNORE ]</strong> field is used to specify how to process null values in the index column of the Unique index.</p>
<p id="EN-US_TOPIC_0000001460561348__p1636261210525">Default value: This parameter is left empty by default. NULL values can be inserted repeatedly.</p>
<p id="EN-US_TOPIC_0000001460561348__p1547195195911">When the inserted data is compared with the original data in the table, the NULL value can be processed in any of the following ways:</p>
<ul id="EN-US_TOPIC_0000001460561348__ul970814364497"><li id="EN-US_TOPIC_0000001460561348__li670811365497">NULLS DISTINCT: NULL values are unequal and can be inserted repeatedly.</li><li id="EN-US_TOPIC_0000001460561348__li10708236104910">NULLS NOT DISTINCT: NULL values are equal. If all index columns are NULL, NULL values cannot be inserted repeatedly. If some index columns are NULL, data can be inserted only when non-null values are different.</li><li id="EN-US_TOPIC_0000001460561348__li77081536124920">NULLS IGNORE: NULL values are skipped during the equivalent comparison. If all index columns are NULL, NULL values can be inserted repeatedly. If some index columns are NULL, data can be inserted only when non-null values are different.</li></ul>
<p id="EN-US_TOPIC_0000001460561348__p1654716518592">The following table lists the behaviors of the three processing modes.</p>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="EN-US_TOPIC_0000001460561348__table1449412571407" frame="border" border="1" rules="all"><caption><b>Table 2 </b>Processing of NULL values in index columns in unique indexes</caption><thead align="left"><tr id="EN-US_TOPIC_0000001460561348__row104951657207"><th align="left" class="cellrowborder" valign="top" width="33.25%" id="mcps1.3.4.2.24.9.2.4.1.1"><p id="EN-US_TOPIC_0000001460561348__p149595719017">Constraint</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="24.529999999999998%" id="mcps1.3.4.2.24.9.2.4.1.2"><p id="EN-US_TOPIC_0000001460561348__p2495057208">All Index Columns Are NULL</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="42.22%" id="mcps1.3.4.2.24.9.2.4.1.3"><p id="EN-US_TOPIC_0000001460561348__p1649535719015">Some Index Columns Are NULL.</p>
</th>
</tr>
</thead>
<tbody><tr id="EN-US_TOPIC_0000001460561348__row94953571505"><td class="cellrowborder" valign="top" width="33.25%" headers="mcps1.3.4.2.24.9.2.4.1.1 "><p id="EN-US_TOPIC_0000001460561348__p174951057901">NULLS DISTINCT</p>
</td>
<td class="cellrowborder" valign="top" width="24.529999999999998%" headers="mcps1.3.4.2.24.9.2.4.1.2 "><p id="EN-US_TOPIC_0000001460561348__p549825711016">Can be inserted repeatedly.</p>
</td>
<td class="cellrowborder" valign="top" width="42.22%" headers="mcps1.3.4.2.24.9.2.4.1.3 "><p id="EN-US_TOPIC_0000001460561348__p149895712010">Can be inserted repeatedly.</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001460561348__row6498165715017"><td class="cellrowborder" valign="top" width="33.25%" headers="mcps1.3.4.2.24.9.2.4.1.1 "><p id="EN-US_TOPIC_0000001460561348__p154981570020">NULLS NOT DISTINCT</p>
</td>
<td class="cellrowborder" valign="top" width="24.529999999999998%" headers="mcps1.3.4.2.24.9.2.4.1.2 "><p id="EN-US_TOPIC_0000001460561348__p64981657107">Cannot be inserted repeatedly.</p>
</td>
<td class="cellrowborder" valign="top" width="42.22%" headers="mcps1.3.4.2.24.9.2.4.1.3 "><p id="EN-US_TOPIC_0000001460561348__p134983576015">Cannot be inserted if the non-null values are equal. Can be inserted if the non-null values are not equal.</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001460561348__row9498557705"><td class="cellrowborder" valign="top" width="33.25%" headers="mcps1.3.4.2.24.9.2.4.1.1 "><p id="EN-US_TOPIC_0000001460561348__p2049811579012">NULLS IGNORE</p>
</td>
<td class="cellrowborder" valign="top" width="24.529999999999998%" headers="mcps1.3.4.2.24.9.2.4.1.2 "><p id="EN-US_TOPIC_0000001460561348__p74983571008">Can be inserted repeatedly.</p>
</td>
<td class="cellrowborder" valign="top" width="42.22%" headers="mcps1.3.4.2.24.9.2.4.1.3 "><p id="EN-US_TOPIC_0000001460561348__p1249916571904">Cannot be inserted if the non-null values are equal. Can be inserted if the non-null values are not equal.</p>
</td>
</tr>
</tbody>
</table>
</div>
<div class="note" id="EN-US_TOPIC_0000001460561348__n5c787c39852f41ee98e8f9aec419aeb3"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="EN-US_TOPIC_0000001460561348__a647bf5485229466f9085fe5db6f6ed2c">If <strong id="EN-US_TOPIC_0000001460561348__b84235270610484">DISTRIBUTE BY REPLICATION</strong> is not specified, the column table that contains only unique values must contain distribution columns.</p>
</div></div>
</li><li id="EN-US_TOPIC_0000001460561348__l61a58f471c2a41178cea62e34b75609e"><strong id="EN-US_TOPIC_0000001460561348__aead44124bc5c4467b08efadb591637ac">PRIMARY KEY index_parameters</strong><p id="EN-US_TOPIC_0000001460561348__a139d3146dc50420b85805015313d97d0"><strong id="EN-US_TOPIC_0000001460561348__ad33d94e660bd41ce88f2504f99a0ef7d">PRIMARY KEY ( column_name [, ... ] ) index_parameters</strong></p>
<p id="EN-US_TOPIC_0000001460561348__a9cbb2d707be14fe591db68ecec5e0786">Specifies the primary key constraint specifies that a column or columns of a table can contain only unique (non-duplicate) and non-null values.</p>
<p id="EN-US_TOPIC_0000001460561348__af35e3b0d1eb8457b9fde40db514c6708">Only one primary key can be specified for a table.</p>
<div class="note" id="EN-US_TOPIC_0000001460561348__n18e8fd59d5ef457cbeec615f6f07d9fe"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="EN-US_TOPIC_0000001460561348__a612f61a539c94ce4841136a1e1d194a6">If <strong id="EN-US_TOPIC_0000001460561348__b18701033944">DISTRIBUTE BY REPLICATION</strong> is not specified, the column set with a primary key constraint must contain distributed columns.</p>
</div></div>
</li><li id="EN-US_TOPIC_0000001460561348__ld504902f528d4b15b74d4e19a9e80627"><strong id="EN-US_TOPIC_0000001460561348__a955d98a5445a42f1a9fa5d6de093af02">DEFERRABLE | NOT DEFERRABLE</strong><p id="EN-US_TOPIC_0000001460561348__a8933428d03e743088b176c549c43cfa0">Controls whether the constraint can be deferred. A constraint that is not deferrable will be checked immediately after every command. Checking of constraints that are deferrable can be postponed until the end of the transaction using the <strong id="EN-US_TOPIC_0000001460561348__b60118629161614">SET CONSTRAINTS</strong> command. <strong id="EN-US_TOPIC_0000001460561348__b37770752161614">NOT DEFERRABLE</strong> is the default value. Currently, only <strong id="EN-US_TOPIC_0000001460561348__b842352706165150">UNIQUE</strong> and <strong id="EN-US_TOPIC_0000001460561348__b842352706165153">PRIMARY KEY</strong> constraints of row-store tables accept this clause. All the other constraints are not deferrable.</p>
</li><li id="EN-US_TOPIC_0000001460561348__li490420236428"><strong id="EN-US_TOPIC_0000001460561348__b194681910164">PARTIAL CLUSTER KEY</strong><p id="EN-US_TOPIC_0000001460561348__p2024122110254">Specifies a partial cluster key for storage. When importing data to a column-store table, you can perform local data sorting by specified columns (single or multiple).</p>
</li><li id="EN-US_TOPIC_0000001460561348__le49188cd0ea9445bb11c4ffba407db2e"><strong id="EN-US_TOPIC_0000001460561348__abbad7cac0fba4d5184597e50e26b2d40">INITIALLY IMMEDIATE | INITIALLY DEFERRED</strong><p id="EN-US_TOPIC_0000001460561348__a23370860b6a340e982a08d6ede865ede">If a constraint is deferrable, this clause specifies the default time to check the constraint.</p>
<ul id="EN-US_TOPIC_0000001460561348__u882f54932fb14e639393bdb51c8f54de"><li id="EN-US_TOPIC_0000001460561348__lc2d668e5ba944b388e26f8ad78eb23d1">If the constraint is <strong id="EN-US_TOPIC_0000001460561348__b44131592161921">INITIALLY IMMEDIATE</strong> (default value), it is checked after each statement.</li><li id="EN-US_TOPIC_0000001460561348__ld299e8bbef5a4cf18d9fe7a0be476c4b">If the constraint is <strong id="EN-US_TOPIC_0000001460561348__b17889208161921">INITIALLY DEFERRED</strong>, it is checked only at the end of the transaction.</li></ul>
<p id="EN-US_TOPIC_0000001460561348__ae2d1db393a0a4242b3665193edc024ab">The constraint check time can be altered using the <strong id="EN-US_TOPIC_0000001460561348__b39739724161921">SET CONSTRAINTS</strong> command.</p>
</li></ul>
</div>
<div class="section" id="EN-US_TOPIC_0000001460561348__section75712037183317"><h4 class="sectiontitle">Examples</h4><p id="EN-US_TOPIC_0000001460561348__p13831105315549">Define a unique column constraint for the table:</p>
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001460561348__screen824712315720"><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></pre></div></td><td class="code"><div><pre><span></span><span class="k">CREATE</span><span class="w"> </span><span class="k">TABLE</span><span class="w"> </span><span class="n">CUSTOMER</span>
<span class="p">(</span><span class="w"> </span>
<span class="w"> </span><span class="n">C_CUSTKEY</span><span class="w"> </span><span class="nb">BIGINT</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="k">CONSTRAINT</span><span class="w"> </span><span class="n">C_CUSTKEY_pk</span><span class="w"> </span><span class="k">PRIMARY</span><span class="w"> </span><span class="k">KEY</span><span class="w"> </span><span class="p">,</span><span class="w"> </span>
<span class="w"> </span><span class="n">C_NAME</span><span class="w"> </span><span class="nb">VARCHAR</span><span class="p">(</span><span class="mi">25</span><span class="p">)</span><span class="w"> </span><span class="p">,</span><span class="w"> </span>
<span class="w"> </span><span class="n">C_ADDRESS</span><span class="w"> </span><span class="nb">VARCHAR</span><span class="p">(</span><span class="mi">40</span><span class="p">)</span><span class="w"> </span><span class="p">,</span><span class="w"> </span>
<span class="w"> </span><span class="n">C_NATIONKEY</span><span class="w"> </span><span class="nb">INT</span><span class="w"> </span><span class="p">,</span><span class="w"> </span>
<span class="w"> </span><span class="n">C_PHONE</span><span class="w"> </span><span class="nb">CHAR</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="w"> </span><span class="n">C_ACCTBAL</span><span class="w"> </span><span class="nb">DECIMAL</span><span class="p">(</span><span class="mi">15</span><span class="p">,</span><span class="mi">2</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="p">(</span><span class="n">C_CUSTKEY</span><span class="p">);</span>
</pre></div></td></tr></table></div>
</div>
<p id="EN-US_TOPIC_0000001460561348__p1783215534547">Define a primary key table constraint for the table. You can define a primary key table constraint on one or more columns of a table:</p>
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001460561348__screen7206193511575"><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></pre></div></td><td class="code"><div><pre><span></span><span class="k">CREATE</span><span class="w"> </span><span class="k">TABLE</span><span class="w"> </span><span class="n">CUSTOMER</span>
<span class="p">(</span><span class="w"> </span>
<span class="w"> </span><span class="n">C_CUSTKEY</span><span class="w"> </span><span class="nb">BIGINT</span><span class="w"> </span><span class="p">,</span><span class="w"> </span>
<span class="w"> </span><span class="n">C_NAME</span><span class="w"> </span><span class="nb">VARCHAR</span><span class="p">(</span><span class="mi">25</span><span class="p">)</span><span class="w"> </span><span class="p">,</span><span class="w"> </span>
<span class="w"> </span><span class="n">C_ADDRESS</span><span class="w"> </span><span class="nb">VARCHAR</span><span class="p">(</span><span class="mi">40</span><span class="p">)</span><span class="w"> </span><span class="p">,</span><span class="w"> </span>
<span class="w"> </span><span class="n">C_NATIONKEY</span><span class="w"> </span><span class="nb">INT</span><span class="w"> </span><span class="p">,</span><span class="w"> </span>
<span class="w"> </span><span class="n">C_PHONE</span><span class="w"> </span><span class="nb">CHAR</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="w"> </span><span class="n">C_ACCTBAL</span><span class="w"> </span><span class="nb">DECIMAL</span><span class="p">(</span><span class="mi">15</span><span class="p">,</span><span class="mi">2</span><span class="p">)</span><span class="w"> </span><span class="p">,</span><span class="w"> </span>
<span class="w"> </span><span class="k">CONSTRAINT</span><span class="w"> </span><span class="n">C_CUSTKEY_KEY</span><span class="w"> </span><span class="k">PRIMARY</span><span class="w"> </span><span class="k">KEY</span><span class="p">(</span><span class="n">C_CUSTKEY</span><span class="p">,</span><span class="n">C_NAME</span><span class="p">)</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="p">(</span><span class="n">C_CUSTKEY</span><span class="p">,</span><span class="n">C_NAME</span><span class="p">);</span>
</pre></div></td></tr></table></div>
</div>
<p id="EN-US_TOPIC_0000001460561348__p883295395410">Define the <strong id="EN-US_TOPIC_0000001460561348__b20639802510338">CHECK</strong> column constraint.</p>
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001460561348__screen97220431583"><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></pre></div></td><td class="code"><div><pre><span></span><span class="k">CREATE</span><span class="w"> </span><span class="k">TABLE</span><span class="w"> </span><span class="n">CUSTOMER</span>
<span class="p">(</span><span class="w"> </span>
<span class="w"> </span><span class="n">C_CUSTKEY</span><span class="w"> </span><span class="nb">BIGINT</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="k">CONSTRAINT</span><span class="w"> </span><span class="n">C_CUSTKEY_pk</span><span class="w"> </span><span class="k">PRIMARY</span><span class="w"> </span><span class="k">KEY</span><span class="w"> </span><span class="p">,</span><span class="w"> </span>
<span class="w"> </span><span class="n">C_NAME</span><span class="w"> </span><span class="nb">VARCHAR</span><span class="p">(</span><span class="mi">25</span><span class="p">)</span><span class="w"> </span><span class="p">,</span><span class="w"> </span>
<span class="w"> </span><span class="n">C_ADDRESS</span><span class="w"> </span><span class="nb">VARCHAR</span><span class="p">(</span><span class="mi">40</span><span class="p">)</span><span class="w"> </span><span class="p">,</span><span class="w"> </span>
<span class="w"> </span><span class="n">C_NATIONKEY</span><span class="w"> </span><span class="nb">INT</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="k">CHECK</span><span class="w"> </span><span class="p">(</span><span class="n">C_NATIONKEY</span><span class="w"> </span><span class="o">&gt;</span><span class="w"> </span><span class="mi">0</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="p">(</span><span class="n">C_CUSTKEY</span><span class="p">);</span>
</pre></div></td></tr></table></div>
</div>
<p id="EN-US_TOPIC_0000001460561348__p12833175318546">Define the <strong id="EN-US_TOPIC_0000001460561348__b52850190910338">CHECK</strong> table constraint:</p>
<pre class="screen" id="EN-US_TOPIC_0000001460561348__screen914013572581">CREATE TABLE CUSTOMER
(
C_CUSTKEY BIGINT NOT NULL CONSTRAINT C_CUSTKEY_pk PRIMARY KEY ,
C_NAME VARCHAR(25) ,
C_ADDRESS VARCHAR(40) ,
C_NATIONKEY INT ,
CONSTRAINT C_CUSTKEY_KEY2 CHECK(C_CUSTKEY &gt; 0 AND C_NAME &lt;&gt; '')
)
DISTRIBUTE BY HASH(C_CUSTKEY);</pre>
<p id="EN-US_TOPIC_0000001460561348__p16833125314542">Create a column-store table and specify the storage format and compression mode:</p>
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001460561348__screen1215719587599"><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></pre></div></td><td class="code"><div><pre><span></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="k">WITH</span><span class="w"> </span><span class="p">(</span><span class="n">ORIENTATION</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">COLUMN</span><span class="p">,</span><span class="w"> </span><span class="n">COMPRESSION</span><span class="o">=</span><span class="n">HIGH</span><span class="p">,</span><span class="n">COLVERSION</span><span class="o">=</span><span class="mi">2</span><span class="p">.</span><span class="mi">0</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>
</pre></div></td></tr></table></div>
</div>
<p id="EN-US_TOPIC_0000001460561348__p78337531549">Use <strong id="EN-US_TOPIC_0000001460561348__b86641658010338">DEFAULT</strong> to declare a default value for column <strong id="EN-US_TOPIC_0000001460561348__b175153636710338">W_STATE</strong>:</p>
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001460561348__screen021814161104"><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></pre></div></td><td class="code"><div><pre><span></span><span class="k">CREATE</span><span class="w"> </span><span class="k">TABLE</span><span class="w"> </span><span class="n">warehouse_t</span>
<span class="p">(</span>
<span class="w"> </span><span class="n">W_WAREHOUSE_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="p">,</span>
<span class="w"> </span><span class="n">W_WAREHOUSE_ID</span><span class="w"> </span><span class="nb">CHAR</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="p">,</span>
<span class="w"> </span><span class="n">W_WAREHOUSE_NAME</span><span class="w"> </span><span class="nb">VARCHAR</span><span class="p">(</span><span class="mi">20</span><span class="p">)</span><span class="w"> </span><span class="k">UNIQUE</span><span class="w"> </span><span class="k">DEFERRABLE</span><span class="p">,</span>
<span class="w"> </span><span class="n">W_WAREHOUSE_SQ_FT</span><span class="w"> </span><span class="nb">INTEGER</span><span class="w"> </span><span class="p">,</span>
<span class="w"> </span><span class="n">W_COUNTY</span><span class="w"> </span><span class="nb">VARCHAR</span><span class="p">(</span><span class="mi">30</span><span class="p">)</span><span class="w"> </span><span class="p">,</span>
<span class="w"> </span><span class="n">W_STATE</span><span class="w"> </span><span class="nb">CHAR</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span><span class="w"> </span><span class="k">DEFAULT</span><span class="w"> </span><span class="s1">'GA'</span><span class="p">,</span>
<span class="w"> </span><span class="n">W_ZIP</span><span class="w"> </span><span class="nb">CHAR</span><span class="p">(</span><span class="mi">10</span><span class="p">)</span><span class="w"> </span>
<span class="p">);</span>
</pre></div></td></tr></table></div>
</div>
<p id="EN-US_TOPIC_0000001460561348__p48347532545">Create the <strong id="EN-US_TOPIC_0000001460561348__b139720502510338">CUSTOMER_bk</strong> table in LIKE mode:</p>
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001460561348__screen979095915610"><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">CREATE</span><span class="w"> </span><span class="k">TABLE</span><span class="w"> </span><span class="n">CUSTOMER_bk</span><span class="w"> </span><span class="p">(</span><span class="k">LIKE</span><span class="w"> </span><span class="n">CUSTOMER</span><span class="w"> </span><span class="k">INCLUDING</span><span class="w"> </span><span class="k">ALL</span><span class="p">);</span>
</pre></div></td></tr></table></div>
</div>
</div>
<div class="section" id="EN-US_TOPIC_0000001460561348__sbd5006c0aa874ae59e4fa1608060e587"><h4 class="sectiontitle">Helpful Links</h4><p id="EN-US_TOPIC_0000001460561348__af68d50a68ca240b5b4b865f60da19c34"><a href="dws_06_0142.html">ALTER TABLE</a>, <a href="dws_06_0276.html">12.101-RENAME TABLE</a>, and <a href="dws_06_0208.html">DROP TABLE</a></p>
</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>