Files
doc-exports/docs/dws/dev/dws_06_0177.html
luhuayi 177cd61a57 DWS DEVG 910.211 version
Reviewed-by: Pruthi, Vineet <vineet.pruthi@t-systems.com>
Co-authored-by: luhuayi <luhuayi@huawei.com>
Co-committed-by: luhuayi <luhuayi@huawei.com>
2025-05-05 07:44:03 +00:00

705 lines
173 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_0000001764675138"></a><a name="EN-US_TOPIC_0000001764675138"></a>
<h1 class="topictitle1">CREATE TABLE</h1>
<div id="body8662426"><div class="section" id="EN-US_TOPIC_0000001764675138__sf337ecb5bde84580afed94be7bbf5fb9"><h4 class="sectiontitle">Function</h4><p id="EN-US_TOPIC_0000001764675138__p1479251195413">Creates a new empty table in the current database.</p>
<p id="EN-US_TOPIC_0000001764675138__p10792712140">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_0000001764675138__s0c57396ef17642e9a39a88ab766472e1"><h4 class="sectiontitle">Precautions</h4><ul id="EN-US_TOPIC_0000001764675138__u833942a091c642dba1f12f016ec573a6"><li id="EN-US_TOPIC_0000001764675138__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_0000001764675138__l504f7aa1a84c4020b9b51a8bff923e10">It is recommended that the number of column-store and HDFS partitioned tables do not exceed 1000.</li><li id="EN-US_TOPIC_0000001764675138__lce538d16b2d64c65ae8ca8377cec854e">The primary key constraint and unique constraint in the table must contain a distribution column.</li><li id="EN-US_TOPIC_0000001764675138__li3989191281015">The data type of the distribution column in an existing table cannot be modified.</li><li id="EN-US_TOPIC_0000001764675138__li5223196162614">A system column cannot be designated as a primary key in a row-store REPLICATION distributed table.</li><li id="EN-US_TOPIC_0000001764675138__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_0000001764675138__le8ecab52de30457fbd82700c5935cf14">Column-store tables support the <strong id="EN-US_TOPIC_0000001764675138__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_0000001764675138__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_0000001764675138__li1650612339613">Whether column-store tables support a delta table is specified by the <strong id="EN-US_TOPIC_0000001764675138__b16709154122318">enable_delta</strong> parameter. The threshold for storing data into a delta table is specified by the <strong id="EN-US_TOPIC_0000001764675138__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_0000001764675138__li62418531059">Multi-temperature tables support only partitioned column-store tables and depend on available OBS tablespaces.</li><li id="EN-US_TOPIC_0000001764675138__li926141319599">Multi-temperature tables support only the default tablespace <strong id="EN-US_TOPIC_0000001764675138__b1378181413559">default_obs_tbs</strong>. If you need to add an OBS tablespace, contact technical support.</li><li id="EN-US_TOPIC_0000001764675138__en-us_topic_0000001342465185_li2637145511359">To create a column-store table, explicitly set <strong id="EN-US_TOPIC_0000001764675138__b156181064712">orientation</strong> to <strong id="EN-US_TOPIC_0000001764675138__b3413181218475">column</strong>. When creating a local table in the storage-compute decoupling edition with all data stored on EVS disks, make sure to explicitly set <strong id="EN-US_TOPIC_0000001764675138__b17411102935411">colversion</strong> to <strong id="EN-US_TOPIC_0000001764675138__b2020873317546">2.0</strong>.</li><li id="EN-US_TOPIC_0000001764675138__li77748500371">Once a table is created, it cannot be switched from a non-V3 table to a V3 table using the <strong id="EN-US_TOPIC_0000001764675138__b10209324123913">ALTER TABLE</strong> syntax. In other words, a non-V3 table with a colversion of 2.0 cannot be converted to a V3 table with a colversion of 3.0.</li><li id="EN-US_TOPIC_0000001764675138__li134315206287">Delta tables and column-store level-2 partitions cannot be set for V3 tables (for example, <strong id="EN-US_TOPIC_0000001764675138__b5103152918215">colversion = 3.0</strong>, storage and compute separated tables).</li><li id="EN-US_TOPIC_0000001764675138__li10682114410224">V3 tables cannot be configured as H-Store tables, hot-and-cold-data-separated tables, or time sequence tables.</li><li id="EN-US_TOPIC_0000001764675138__li19352144719251">Global temporary tables and temporary tables cannot be created for V3 tables. Any created temporary tables are automatically converted to temporary tables with colversion 2.0.</li></ul>
<div class="warning" id="EN-US_TOPIC_0000001764675138__note17212183121615"><span class="warningtitle"><img src="public_sys-resources/warning_3.0-en-us.png"> </span><div class="warningbody"><ul id="EN-US_TOPIC_0000001764675138__en-us_topic_0000001188429064_ul135541151592"><li id="EN-US_TOPIC_0000001764675138__en-us_topic_0000001188429064_li195421418690">You are not advised to specify a user-defined tablespace when creating an ordinary table.</li><li id="EN-US_TOPIC_0000001764675138__en-us_topic_0000001188429064_li6889171919916">Do not specify the <strong id="EN-US_TOPIC_0000001764675138__en-us_topic_0000001188429064_b1216843791115">COMPRESS</strong> compression attribute when creating a row-store table.</li><li id="EN-US_TOPIC_0000001764675138__en-us_topic_0000001188429064_li539742961012">When creating a hash-distributed table object, ensure that data is evenly distributed. (For a table with more than 10 GB data, the skew rate must be less than 10%.)</li><li id="EN-US_TOPIC_0000001764675138__en-us_topic_0000001188429064_li155418151395">When creating a table object for <strong id="EN-US_TOPIC_0000001764675138__en-us_topic_0000001188429064_b12987104651110">REPLICATION</strong> distribution, ensure that the number of rows in the table is less than 1 million.</li><li id="EN-US_TOPIC_0000001764675138__en-us_topic_0000001188429064_li91856451993">When creating an H-Store table, ensure that the database GUC parameter settings meet the following requirements:<ul id="EN-US_TOPIC_0000001764675138__en-us_topic_0000001188429064_ul822142062019"><li id="EN-US_TOPIC_0000001764675138__en-us_topic_0000001188429064_li15221142012019"><strong id="EN-US_TOPIC_0000001764675138__en-us_topic_0000001188429064_b1941165617118">autovacuum</strong> is set to <strong id="EN-US_TOPIC_0000001764675138__en-us_topic_0000001188429064_b1741119566111">on</strong>.</li><li id="EN-US_TOPIC_0000001764675138__en-us_topic_0000001188429064_li2221620102016">The value of <strong id="EN-US_TOPIC_0000001764675138__en-us_topic_0000001188429064_b13131512122">autovacuum_max_workers_hstore</strong> is greater than <strong id="EN-US_TOPIC_0000001764675138__en-us_topic_0000001188429064_b139193611122">0</strong>.</li><li id="EN-US_TOPIC_0000001764675138__en-us_topic_0000001188429064_li162211720202019">The value of <strong id="EN-US_TOPIC_0000001764675138__en-us_topic_0000001188429064_b1945681361211">autovacuum_max_workers</strong> is greater than that of <strong id="EN-US_TOPIC_0000001764675138__en-us_topic_0000001188429064_b1279417166122">autovacuum_max_workers_hstore</strong>.</li></ul>
</li><li id="EN-US_TOPIC_0000001764675138__en-us_topic_0000001188429064_li14554815291">For a large table (with more than 50 million rows of data) that contains the time field, the table must be designed as a partition table and the partition interval must be properly designed based on the query characteristics.</li><li id="EN-US_TOPIC_0000001764675138__en-us_topic_0000001188429064_li205545151496">For a table where a large amount of data needs to be added, deleted, or modified, it is recommended that the number of indexes be less than or equal to three. The maximum number of indexes is five.</li><li id="EN-US_TOPIC_0000001764675138__en-us_topic_0000001188429064_li147065499919">For more information about development and design specifications, see "GaussDB(DWS) Development and Design Proposal" in the <em id="EN-US_TOPIC_0000001764675138__en-us_topic_0000001188429064_i20225192715126">Data Warehouse Service (DWS) Developer Guide</em>.</li></ul>
</div></div>
</div>
<div class="section" id="EN-US_TOPIC_0000001764675138__s24f4eafc7fd349969c837eaaf863b260"><h4 class="sectiontitle">Syntax</h4><div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001764675138__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="err">}</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_0000001764675138__u51eab43ce2b24d86b3e1d981e21fa644"><li id="EN-US_TOPIC_0000001764675138__l4f184948a45942409141cdb1165b3d81"><strong id="EN-US_TOPIC_0000001764675138__b84235270610227">column_constraint</strong> is as follows:<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001764675138__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>
<span class="normal">11</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="o">|</span>
<span class="w"> </span><span class="k">REFERENCES</span><span class="w"> </span><span class="n">reftable</span><span class="w"> </span><span class="p">[</span><span class="w"> </span><span class="p">(</span><span class="w"> </span><span class="n">refcolumn</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_0000001764675138__u070f826fe6544b61872abf44e6512111"><li id="EN-US_TOPIC_0000001764675138__l072891e7e4844f89bf28ecb50eee1b74"><strong id="EN-US_TOPIC_0000001764675138__b842352706171324">compress_mode</strong> of a column is as follows:<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001764675138__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_0000001764675138__l5447f854591b42e1a0b28e890cf928d1"><strong id="EN-US_TOPIC_0000001764675138__b84235270610618">table_constraint</strong> is as follows:<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001764675138__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_0000001764675138__u147ed9cab742413da2c22e8026d659ec"><li id="EN-US_TOPIC_0000001764675138__l8cb55d220954403088edf67e4e32f784"><strong id="EN-US_TOPIC_0000001764675138__b84235270610642">like_option</strong> is as follows:<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001764675138__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_0000001764675138__li04965417494"><strong id="EN-US_TOPIC_0000001764675138__b8423527069548">index_parameters</strong> is as follows:<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001764675138__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_0000001764675138__section6798194315100"><h4 class="sectiontitle">Table Design Reference</h4><p id="EN-US_TOPIC_0000001764675138__p658491121210">GaussDB(DWS) is compatible with the PostgreSQL ecosystem. Row storage and its B-tree index are similar to those of PostgreSQL. Column storage and its index are self-developed. When creating a table, it is crucial to choose the right storage method, distribution column, partition key, and index. This ensures efficient data access during SQL execution, reducing I/O consumption. The following figure illustrates the process from SQL statement initiation to data acquisition, helping you understand the function of each technical method for performance optimization.</p>
</div>
<p id="EN-US_TOPIC_0000001764675138__p10584511151217"><span><img id="EN-US_TOPIC_0000001764675138__image155841011101218" src="figure/en-us_image_0000002012629900.png"></span></p>
<ol id="EN-US_TOPIC_0000001764675138__ol95840112126"><li id="EN-US_TOPIC_0000001764675138__li15584211161215">When the SQL statement is executed, the partition table is optimized using the Partition Column to pinpoint the specific partition.</li><li id="EN-US_TOPIC_0000001764675138__li75841011101219">The Distribute Column is used in a distributed hash table to quickly identify the data shard where the data resides. The data shard is located on a DN in a storage-compute coupled architecture, while in a storage-compute decoupled architecture, it is located on a bucket.</li><li id="EN-US_TOPIC_0000001764675138__li1658471110124">In row-store mode, B-tree is used to quickly locate the data page. In column-store mode, the <strong id="EN-US_TOPIC_0000001764675138__b46724146">min-max</strong> index is used to quickly locate the CU data block that may contain relevant data. This index is particularly effective when filtering on the PCK column.</li><li id="EN-US_TOPIC_0000001764675138__li75842111122">The system automatically maintains the <strong id="EN-US_TOPIC_0000001764675138__b25388797">min-max</strong> index for all columns in the column-store mode. There is no need for manual index definition. The <strong id="EN-US_TOPIC_0000001764675138__b1144712221989">min-max</strong> index is used for coarse filtering. CU data blocks meeting the min-max condition may not contain data rows that meet the filter condition. If a bitmap column is defined, the bitmap index can quickly locate the row number of data that meets the filter condition in the CU. For ordered CUs, binary search is also used to quickly locate the row number of data.</li><li id="EN-US_TOPIC_0000001764675138__li458481181220">Column storage supports B-tree and GIN indexes, which can quickly locate the CU and row number of data that meets the conditions. However, due to high index maintenance costs, it is advised to use bitmap indexes instead unless there are high performance requirements for point queries.</li></ol>
<p id="EN-US_TOPIC_0000001764675138__p18990153101319">The following table lists the existing optimization methods of GaussDB(DWS).</p>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="EN-US_TOPIC_0000001764675138__table20910153131512" frame="border" border="1" rules="all"><caption><b>Table 1 </b>Optimization methods</caption><thead align="left"><tr id="EN-US_TOPIC_0000001764675138__row139111438152"><th align="left" class="cellrowborder" valign="top" width="8%" id="mcps1.3.8.2.6.1.1"><p id="EN-US_TOPIC_0000001764675138__p742202115153"><strong id="EN-US_TOPIC_0000001764675138__b991183713111">No.</strong></p>
</th>
<th align="left" class="cellrowborder" valign="top" width="15%" id="mcps1.3.8.2.6.1.2"><p id="EN-US_TOPIC_0000001764675138__p1642221111514">Method</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="36%" id="mcps1.3.8.2.6.1.3"><p id="EN-US_TOPIC_0000001764675138__p184217219157">Usage</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="26%" id="mcps1.3.8.2.6.1.4"><p id="EN-US_TOPIC_0000001764675138__p1543202131516">Example SQL</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="15%" id="mcps1.3.8.2.6.1.5"><p id="EN-US_TOPIC_0000001764675138__p1443421121518">Modifiable After Creation</p>
</th>
</tr>
</thead>
<tbody><tr id="EN-US_TOPIC_0000001764675138__row149126331514"><td class="cellrowborder" valign="top" width="8%" headers="mcps1.3.8.2.6.1.1 "><p id="EN-US_TOPIC_0000001764675138__p636003019157">1</p>
</td>
<td class="cellrowborder" valign="top" width="15%" headers="mcps1.3.8.2.6.1.2 "><p id="EN-US_TOPIC_0000001764675138__p2360173013158">String</p>
</td>
<td class="cellrowborder" valign="top" width="36%" headers="mcps1.3.8.2.6.1.3 "><ol id="EN-US_TOPIC_0000001764675138__ol18171964176"><li id="EN-US_TOPIC_0000001764675138__li161716613178">The string type has slower performance compared to the fixed-length type, so it is not recommended for scenarios where the fixed-length type is more suitable.</li><li id="EN-US_TOPIC_0000001764675138__li5171691714">If the specified length is less than 16, performance will be significantly improved.</li></ol>
</td>
<td class="cellrowborder" valign="top" width="26%" headers="mcps1.3.8.2.6.1.4 "><p id="EN-US_TOPIC_0000001764675138__p53611430151516">-</p>
</td>
<td class="cellrowborder" valign="top" width="15%" headers="mcps1.3.8.2.6.1.5 "><p id="EN-US_TOPIC_0000001764675138__p1236113071513">Yes (The existing data can be rewritten.)</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001764675138__row199121636151"><td class="cellrowborder" valign="top" width="8%" headers="mcps1.3.8.2.6.1.1 "><p id="EN-US_TOPIC_0000001764675138__p1636153041515">2</p>
</td>
<td class="cellrowborder" valign="top" width="15%" headers="mcps1.3.8.2.6.1.2 "><p id="EN-US_TOPIC_0000001764675138__p13613304153">Numeric</p>
</td>
<td class="cellrowborder" valign="top" width="36%" headers="mcps1.3.8.2.6.1.3 "><p id="EN-US_TOPIC_0000001764675138__p336253016151">Specifying precision for the numeric type is essential for improving performance. It is not advisable to use the numeric type without specifying precision.</p>
</td>
<td class="cellrowborder" valign="top" width="26%" headers="mcps1.3.8.2.6.1.4 "><p id="EN-US_TOPIC_0000001764675138__p1336203021513">-</p>
</td>
<td class="cellrowborder" valign="top" width="15%" headers="mcps1.3.8.2.6.1.5 "><p id="EN-US_TOPIC_0000001764675138__p9362230101513">Yes (The existing data can be rewritten.)</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001764675138__row591373181516"><td class="cellrowborder" valign="top" width="8%" headers="mcps1.3.8.2.6.1.1 "><p id="EN-US_TOPIC_0000001764675138__p83625306159">3</p>
</td>
<td class="cellrowborder" valign="top" width="15%" headers="mcps1.3.8.2.6.1.2 "><p id="EN-US_TOPIC_0000001764675138__p236273031519">Partition by Column</p>
</td>
<td class="cellrowborder" valign="top" width="36%" headers="mcps1.3.8.2.6.1.3 "><ol id="EN-US_TOPIC_0000001764675138__ol15897154851716"><li id="EN-US_TOPIC_0000001764675138__li889712489178">This requires user-defined settings and is designed for partitioned tables. Pruning is possible using partition keys and partition-wise joins are supported. This method is suitable for equality and range queries.</li><li id="EN-US_TOPIC_0000001764675138__li2897104891718">Having more than 1000 partitions is not recommended, and it is advisable to limit the number of partition columns to two.</li></ol>
</td>
<td class="cellrowborder" valign="top" width="26%" headers="mcps1.3.8.2.6.1.4 "><div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001764675138__screen422682413181"><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">SELECT</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="k">FROM</span><span class="w"> </span><span class="n">t1</span><span class="w"> </span><span class="k">WHERE</span><span class="w"> </span><span class="n">t1</span><span class="p">.</span><span class="n">c1</span><span class="o">=</span><span class="s1">'p1'</span><span class="p">;</span>
</pre></div></td></tr></table></div>
</div>
</td>
<td class="cellrowborder" valign="top" width="15%" headers="mcps1.3.8.2.6.1.5 "><p id="EN-US_TOPIC_0000001764675138__p43630303153">No (You need to create a new table to make modifications.)</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001764675138__row1391316311513"><td class="cellrowborder" valign="top" width="8%" headers="mcps1.3.8.2.6.1.1 "><p id="EN-US_TOPIC_0000001764675138__p8363153011159">4</p>
</td>
<td class="cellrowborder" valign="top" width="15%" headers="mcps1.3.8.2.6.1.2 "><p id="EN-US_TOPIC_0000001764675138__p9363130101514">secondary_part_column</p>
</td>
<td class="cellrowborder" valign="top" width="36%" headers="mcps1.3.8.2.6.1.3 "><ol id="EN-US_TOPIC_0000001764675138__ol15315144411178"><li id="EN-US_TOPIC_0000001764675138__li20315164431715">This requires user-defined settings and is applicable only to column-store tables and equality queries.</li><li id="EN-US_TOPIC_0000001764675138__li13151644151711">Specify a level-2 partition on the most commonly used equivalent filter.</li></ol>
</td>
<td class="cellrowborder" valign="top" width="26%" headers="mcps1.3.8.2.6.1.4 "><div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001764675138__screen87162091912"><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">SELECT</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="k">FROM</span><span class="w"> </span><span class="n">t1</span><span class="w"> </span><span class="k">WHERE</span><span class="w"> </span><span class="n">t1</span><span class="p">.</span><span class="n">c1</span><span class="o">=</span><span class="s1">'p1'</span><span class="p">;</span>
</pre></div></td></tr></table></div>
</div>
</td>
<td class="cellrowborder" valign="top" width="15%" headers="mcps1.3.8.2.6.1.5 "><p id="EN-US_TOPIC_0000001764675138__p9363730131512">No (You need to create a new table to make modifications.)</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001764675138__row1791419318153"><td class="cellrowborder" valign="top" width="8%" headers="mcps1.3.8.2.6.1.1 "><p id="EN-US_TOPIC_0000001764675138__p4363163014152">5</p>
</td>
<td class="cellrowborder" valign="top" width="15%" headers="mcps1.3.8.2.6.1.2 "><p id="EN-US_TOPIC_0000001764675138__p8363113014152">Distribute by Column</p>
</td>
<td class="cellrowborder" valign="top" width="36%" headers="mcps1.3.8.2.6.1.3 "><p id="EN-US_TOPIC_0000001764675138__p5363163011156">This requires user-defined settings and is suitable for join fields that require frequent <strong id="EN-US_TOPIC_0000001764675138__b1064517327449">GROUP BY</strong> or multi-table joins. It reduces data shuffling through local joins and is ideal for equality queries.</p>
</td>
<td class="cellrowborder" valign="top" width="26%" headers="mcps1.3.8.2.6.1.4 "><div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001764675138__screen15707192381911"><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">SELECT</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="k">FROM</span><span class="w"> </span><span class="n">t1</span><span class="w"> </span><span class="k">join</span><span class="w"> </span><span class="n">t2</span><span class="w"> </span><span class="k">on</span><span class="w"> </span><span class="n">t1</span><span class="p">.</span><span class="n">c3</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">t2</span><span class="p">.</span><span class="n">c1</span><span class="p">;</span>
</pre></div></td></tr></table></div>
</div>
</td>
<td class="cellrowborder" valign="top" width="15%" headers="mcps1.3.8.2.6.1.5 "><p id="EN-US_TOPIC_0000001764675138__p536416308152">No (You need to create a new table to make modifications.)</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001764675138__row1291493101514"><td class="cellrowborder" valign="top" width="8%" headers="mcps1.3.8.2.6.1.1 "><p id="EN-US_TOPIC_0000001764675138__p1136443013150">6</p>
</td>
<td class="cellrowborder" valign="top" width="15%" headers="mcps1.3.8.2.6.1.2 "><p id="EN-US_TOPIC_0000001764675138__p19364430151519">Bitmap column</p>
</td>
<td class="cellrowborder" valign="top" width="36%" headers="mcps1.3.8.2.6.1.3 "><p id="EN-US_TOPIC_0000001764675138__p136411301155">Define the bitmap index (cardinality ≤ 32) or bloom filter (cardinality &gt; 32) based on the repeated values in the CU. This method is applicable to equivalent queries of varchar or text type columns. It is advised to create indexes on columns involved in the <strong id="EN-US_TOPIC_0000001764675138__b719616495113">WHERE</strong> condition.</p>
</td>
<td class="cellrowborder" valign="top" width="26%" headers="mcps1.3.8.2.6.1.4 "><div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001764675138__screen617615289194"><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">SELECT</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="k">FROM</span><span class="w"> </span><span class="n">t1</span><span class="w"> </span><span class="k">WHERE</span><span class="w"> </span><span class="n">t1</span><span class="p">.</span><span class="n">c4</span><span class="o">=</span><span class="s1">'hello'</span><span class="p">;</span>
</pre></div></td></tr></table></div>
</div>
</td>
<td class="cellrowborder" valign="top" width="15%" headers="mcps1.3.8.2.6.1.5 "><p id="EN-US_TOPIC_0000001764675138__p7364133061510">Yes (Modification does not rewrite existing data. Only the new data is affected.)</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001764675138__row69141341518"><td class="cellrowborder" valign="top" width="8%" headers="mcps1.3.8.2.6.1.1 "><p id="EN-US_TOPIC_0000001764675138__p1136414307156">7</p>
</td>
<td class="cellrowborder" valign="top" width="15%" headers="mcps1.3.8.2.6.1.2 "><p id="EN-US_TOPIC_0000001764675138__p2364183018157"><strong id="EN-US_TOPIC_0000001764675138__b59922018144714">min-max</strong> index</p>
</td>
<td class="cellrowborder" valign="top" width="36%" headers="mcps1.3.8.2.6.1.3 "><ol id="EN-US_TOPIC_0000001764675138__ol10673553141611"><li id="EN-US_TOPIC_0000001764675138__li1673853141615">The <strong id="EN-US_TOPIC_0000001764675138__b393362364711">min-max</strong> index is automatically generated and can be used for both equality and range queries.</li><li id="EN-US_TOPIC_0000001764675138__li76735538169">The <strong id="EN-US_TOPIC_0000001764675138__b104916334472">min-max</strong> filtering effect depends on the data order. Specifying the PCK column enhances the filtering effect.</li></ol>
</td>
<td class="cellrowborder" valign="top" width="26%" headers="mcps1.3.8.2.6.1.4 "><div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001764675138__screen923783381912"><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">SELECT</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="k">FROM</span><span class="w"> </span><span class="n">t1</span><span class="w"> </span><span class="k">WHERE</span><span class="w"> </span><span class="n">c3</span><span class="w"> </span><span class="o">&gt;</span><span class="w"> </span><span class="mi">100</span><span class="w"> </span><span class="k">and</span><span class="w"> </span><span class="n">c3</span><span class="w"> </span><span class="o">&lt;</span><span class="w"> </span><span class="mi">200</span><span class="p">;</span>
</pre></div></td></tr></table></div>
</div>
</td>
<td class="cellrowborder" valign="top" width="15%" headers="mcps1.3.8.2.6.1.5 "><p id="EN-US_TOPIC_0000001764675138__p336513304157">Yes (The PCK columns can be modified. Modification does not rewrite existing data and only the new data is affected.)</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001764675138__row299319136156"><td class="cellrowborder" valign="top" width="8%" headers="mcps1.3.8.2.6.1.1 "><p id="EN-US_TOPIC_0000001764675138__p236583010154">8</p>
</td>
<td class="cellrowborder" valign="top" width="15%" headers="mcps1.3.8.2.6.1.2 "><p id="EN-US_TOPIC_0000001764675138__p1365203061511">Primary key (B-tree index)</p>
</td>
<td class="cellrowborder" valign="top" width="36%" headers="mcps1.3.8.2.6.1.3 "><ol id="EN-US_TOPIC_0000001764675138__ol14948845171617"><li id="EN-US_TOPIC_0000001764675138__li19481045141610">UPSERT data import strongly depends on the primary key and needs to be customized. It is applicable to equality and range queries. We suggest limiting the number of columns to five or fewer.</li><li id="EN-US_TOPIC_0000001764675138__li294894591616">If service requirements are met, it is better to use fixed-length type columns. During definition, place columns with more distinct values at the beginning.</li></ol>
</td>
<td class="cellrowborder" valign="top" width="26%" headers="mcps1.3.8.2.6.1.4 "><div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001764675138__screen480337121911"><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">SELECT</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="k">FROM</span><span class="w"> </span><span class="n">t1</span><span class="w"> </span><span class="k">WHERE</span><span class="w"> </span><span class="n">c3</span><span class="w"> </span><span class="o">&gt;</span><span class="w"> </span><span class="mi">100</span><span class="w"> </span><span class="k">and</span><span class="w"> </span><span class="n">c3</span><span class="w"> </span><span class="o">&lt;</span><span class="w"> </span><span class="mi">200</span><span class="p">;</span>
</pre></div></td></tr></table></div>
</div>
</td>
<td class="cellrowborder" valign="top" width="15%" headers="mcps1.3.8.2.6.1.5 "><p id="EN-US_TOPIC_0000001764675138__p43651030141514">Yes (The index can be modified and re-created.)</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001764675138__row12994111310157"><td class="cellrowborder" valign="top" width="8%" headers="mcps1.3.8.2.6.1.1 "><p id="EN-US_TOPIC_0000001764675138__p16424103041516">9</p>
</td>
<td class="cellrowborder" valign="top" width="15%" headers="mcps1.3.8.2.6.1.2 "><p id="EN-US_TOPIC_0000001764675138__p53651305155">GIN index</p>
</td>
<td class="cellrowborder" valign="top" width="36%" headers="mcps1.3.8.2.6.1.3 "><ol id="EN-US_TOPIC_0000001764675138__ol9365330141512"><li id="EN-US_TOPIC_0000001764675138__li8365153041511">This requires user-defined settings and is suitable for multi-condition equality queries. Avoid using columns with more than 1 million distinct values.</li><li id="EN-US_TOPIC_0000001764675138__li1836513041519">It is recommended when the data volume after filtering is less than 1000. If the data volume remains large after filtering, it is not recommended.</li></ol>
</td>
<td class="cellrowborder" valign="top" width="26%" headers="mcps1.3.8.2.6.1.4 "><div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001764675138__screen10951194014190"><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">SELECT</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="k">FROM</span><span class="w"> </span><span class="n">t1</span><span class="w"> </span><span class="k">WHERE</span><span class="w"> </span><span class="n">c1</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">100</span><span class="w"> </span><span class="k">and</span><span class="w"> </span><span class="n">c3</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">200</span><span class="w"> </span><span class="k">and</span><span class="w"> </span><span class="n">c2</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">105</span><span class="p">;</span>
</pre></div></td></tr></table></div>
</div>
</td>
<td class="cellrowborder" valign="top" width="15%" headers="mcps1.3.8.2.6.1.5 "><p id="EN-US_TOPIC_0000001764675138__p43661430131516">Yes (The index can be modified and re-created.)</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001764675138__row1899561331516"><td class="cellrowborder" valign="top" width="8%" headers="mcps1.3.8.2.6.1.1 "><p id="EN-US_TOPIC_0000001764675138__p11366193091513">10</p>
</td>
<td class="cellrowborder" valign="top" width="15%" headers="mcps1.3.8.2.6.1.2 "><p id="EN-US_TOPIC_0000001764675138__p163661830141513">Orientation=column/row</p>
</td>
<td class="cellrowborder" valign="top" width="36%" headers="mcps1.3.8.2.6.1.3 "><p id="EN-US_TOPIC_0000001764675138__p19366123051512">This method specifies whether a table is stored in rows or columns. Row-store tables cannot be compressed and are best suited for point queries and frequent updates. Column-store tables can be compressed and are ideal for analysis purposes. </p>
</td>
<td class="cellrowborder" valign="top" width="26%" headers="mcps1.3.8.2.6.1.4 "><p id="EN-US_TOPIC_0000001764675138__p1136614302150">-</p>
</td>
<td class="cellrowborder" valign="top" width="15%" headers="mcps1.3.8.2.6.1.5 "><p id="EN-US_TOPIC_0000001764675138__p9366183011511">No (You need to create a new table to make modifications.)</p>
</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="EN-US_TOPIC_0000001764675138__s1a0c1ce222bb46dfb68a016610aea3a5"><h4 class="sectiontitle">Parameters</h4><ul id="EN-US_TOPIC_0000001764675138__u4a81a0d707ae45068ea150166c1b249d"><li id="EN-US_TOPIC_0000001764675138__lf971c986fe2e4125be8a8f625f6affd5"><strong id="EN-US_TOPIC_0000001764675138__a4ee5d12f41554c0a8148e84e32b06679">UNLOGGED</strong><p id="EN-US_TOPIC_0000001764675138__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_0000001764675138__aa033b20b81a042e9b41d306fa692ad2b">Usage scenario: Unlogged tables do not ensure safe data. You can back up data before using unlogged tables; for example, you should back up the data before a system upgrade.</p>
<p id="EN-US_TOPIC_0000001764675138__a2f1c759659684f7394c49bb0ca2b0412">Troubleshooting: If data is missing in the indexes of unlogged tables due to some unexpected operations such as an unclean shutdown, you should re-create the indexes with errors.</p>
<div class="notice" id="EN-US_TOPIC_0000001764675138__note6872102415351"><span class="noticetitle"><img src="public_sys-resources/notice_3.0-en-us.png"> </span><div class="noticebody"><ol id="EN-US_TOPIC_0000001764675138__ol136475205919"><li id="EN-US_TOPIC_0000001764675138__li736416518595">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.</li><li id="EN-US_TOPIC_0000001764675138__li143641055593">Starting from version 9.1.0, UNLOGGED tables are automatically saved in the <strong id="EN-US_TOPIC_0000001764675138__b248524117599">pg_unlogged</strong> tablespace and cannot be moved or assigned to other tablespaces.</li><li id="EN-US_TOPIC_0000001764675138__li9364185205914">After an earlier version is upgraded to 9.1.0, the UNLOGGED table created in the earlier version is still stored in the original tablespace.</li><li id="EN-US_TOPIC_0000001764675138__li203649511594">If the instance restarts unexpectedly, the UNLOGGED table will be reset, which can impact the instance's recovery time objective (RTO). Version 9.1.0 has a script called <strong id="EN-US_TOPIC_0000001764675138__b369195216019">switch_unlogged_tablespace.py</strong> that can move unlogged tables to optimize the recovery time objective (RTO). This script works together with the GUC parameter <strong id="EN-US_TOPIC_0000001764675138__b1528950113">enable_unlogged_tablespace_compat</strong>.</li></ol>
</div></div>
</li><li id="EN-US_TOPIC_0000001764675138__l40601c13ccdb4b5d85be38edd4f99676"><a name="EN-US_TOPIC_0000001764675138__l40601c13ccdb4b5d85be38edd4f99676"></a><a name="l40601c13ccdb4b5d85be38edd4f99676"></a><strong id="EN-US_TOPIC_0000001764675138__a89e3dc3abfac4c428089799d71037e02">GLOBAL | LOCAL</strong> | <strong id="EN-US_TOPIC_0000001764675138__b18097713339">VOLATILE</strong><p id="EN-US_TOPIC_0000001764675138__p23435388815">Specify the keywords <strong id="EN-US_TOPIC_0000001764675138__b83181813235">GLOBAL</strong>, <strong id="EN-US_TOPIC_0000001764675138__b1552921102311">LOCAL</strong>, and <strong id="EN-US_TOPIC_0000001764675138__b1895412402315">VOLATILE</strong> before <strong id="EN-US_TOPIC_0000001764675138__b1385912321239">TEMP</strong> or <strong id="EN-US_TOPIC_0000001764675138__b177113710232">TEMPORARY</strong> to create temporary tables with different attributes. Global temporary tables are supported only by 8.2.1.220 and later cluster versions.</p>
<ul id="EN-US_TOPIC_0000001764675138__ul27695398547"><li id="EN-US_TOPIC_0000001764675138__li57696392541">If <strong id="EN-US_TOPIC_0000001764675138__b1750114642317">LOCAL</strong> is specified, a local temporary table is created.</li><li id="EN-US_TOPIC_0000001764675138__li8653527172218">If keyword <strong id="EN-US_TOPIC_0000001764675138__b201628165154">GLOBAL</strong> is specified, the attributes of the temporary table depend on the GUC parameter <strong id="EN-US_TOPIC_0000001764675138__b980812517168">enable_global_temp_table</strong>. The default value of this parameter is <strong id="EN-US_TOPIC_0000001764675138__b1955992912166">ON</strong>.<p id="EN-US_TOPIC_0000001764675138__p58489306235">If <strong id="EN-US_TOPIC_0000001764675138__b196011723181914">enable_global_temp_tabl</strong> is set to <strong id="EN-US_TOPIC_0000001764675138__b9484153471910">on</strong>, a global temporary table <strong id="EN-US_TOPIC_0000001764675138__b1949195417191">GLOBAL</strong> is created.</p>
<p id="EN-US_TOPIC_0000001764675138__p7624173216234">If <strong id="EN-US_TOPIC_0000001764675138__b1621050182115">enable_global_temp_tabl</strong> is set to <strong id="EN-US_TOPIC_0000001764675138__b125811612216">off,</strong> a local temporary table <strong id="EN-US_TOPIC_0000001764675138__b1097205772210">LOCAL</strong> is created. You can also specify keyword <strong id="EN-US_TOPIC_0000001764675138__b15356195112412">LOCAL</strong> to reach the same effect.</p>
</li><li id="EN-US_TOPIC_0000001764675138__li2039414965517">If <strong id="EN-US_TOPIC_0000001764675138__b1441252112516">VOLATILE</strong> is specified, a temporary volatile table is created.</li><li id="EN-US_TOPIC_0000001764675138__li51193101354">If <strong id="EN-US_TOPIC_0000001764675138__b7788161011116">default_temptable_type</strong> is set to <strong id="EN-US_TOPIC_0000001764675138__b854413145119">local</strong>, temporary tables created without keywords are local temporary tables. If <strong id="EN-US_TOPIC_0000001764675138__b0573162314110">default_temptable_type</strong> is set to <strong id="EN-US_TOPIC_0000001764675138__b174444263111">volatile</strong>, temporary tables created without keywords are volatile temporary tables.</li></ul>
</li><li id="EN-US_TOPIC_0000001764675138__la8c031f4e4834cb0a68578e03dfdc407"><strong id="EN-US_TOPIC_0000001764675138__ad29cbd42d25f431baea8a5372eb9688a">TEMPORARY | TEMP</strong><p id="EN-US_TOPIC_0000001764675138__ade96caf3b58a440e9f1bc1815a7aa881">If <strong id="EN-US_TOPIC_0000001764675138__b842352706214543">TEMP</strong> or <strong id="EN-US_TOPIC_0000001764675138__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_0000001764675138__b8423527069813">TEMP</strong> is equivalent to <strong id="EN-US_TOPIC_0000001764675138__b8423527069818">TEMPORARY</strong>.</p>
<div class="notice" id="EN-US_TOPIC_0000001764675138__n6e16cd1e50d04bedbca2c396dfc17987"><span class="noticetitle"><img src="public_sys-resources/notice_3.0-en-us.png"> </span><div class="noticebody"><ul id="EN-US_TOPIC_0000001764675138__u4169b31d76e341d8bcf794eb1894a35c"><li id="EN-US_TOPIC_0000001764675138__lf03d0d8803e4428b9429afd47e61ca02">Local or volatile temporary tables are visible to the current session through schema of the <strong id="EN-US_TOPIC_0000001764675138__b8423527069832">pg_temp</strong> start. Users should not delete schema started with <strong id="EN-US_TOPIC_0000001764675138__b8423527069846">pg_temp</strong>, <strong id="EN-US_TOPIC_0000001764675138__b8423527069851">pg_toast_temp</strong>.</li><li id="EN-US_TOPIC_0000001764675138__l08317ce8988e468486b25577e2c864ff">If <strong id="EN-US_TOPIC_0000001764675138__b842352706994">TEMPORARY</strong> or <strong id="EN-US_TOPIC_0000001764675138__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_0000001764675138__b8423527069915">pg_temp_</strong>, the table is created as a temporary table.</li><li id="EN-US_TOPIC_0000001764675138__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_0000001764675138__ul17375184116578"><li id="EN-US_TOPIC_0000001764675138__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_0000001764675138__li18190645102317">Currently, volatile temporary tables do not support table structure modification, such as <strong id="EN-US_TOPIC_0000001764675138__b145641419811">ALTER</strong> and <strong id="EN-US_TOPIC_0000001764675138__b49143189813">GRANT</strong>.</li><li id="EN-US_TOPIC_0000001764675138__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_0000001764675138__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_0000001764675138__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_0000001764675138__li896615592810">Views cannot be created based on volatile temporary tables.</li><li id="EN-US_TOPIC_0000001764675138__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_0000001764675138__b19991650184919">pg_volatile</strong>.</li><li id="EN-US_TOPIC_0000001764675138__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><li id="EN-US_TOPIC_0000001764675138__li79731839111512">Similar to common tables, all metadata in global temporary tables is stored in system catalogs.<ul id="EN-US_TOPIC_0000001764675138__ul14214755102017"><li id="EN-US_TOPIC_0000001764675138__li109631044515">The difference between a global temporary table and a local temporary table is that in a global temporary table, the metadata is not deleted when a session exits, but the session data is deleted. Data of different sessions is independent but shares the metadata of the same global temporary table.</li><li id="EN-US_TOPIC_0000001764675138__li127741844121810">A global temporary table has a schema that is similar to a regular table, unlike a local or volatile temporary table which has a schema starting with <strong id="EN-US_TOPIC_0000001764675138__b1873911371513">pg_temp</strong>. This means that a global temporary table can have the same name as a local or volatile temporary table.</li><li id="EN-US_TOPIC_0000001764675138__li2095316782111">Global 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_0000001764675138__li873620910513">Operations cannot be performed on global temporary tables of other logical clusters.</li></ul>
</li></ul>
</div></div>
</li><li id="EN-US_TOPIC_0000001764675138__lc929efc9948741d3a177e98a1aefbbe4"><strong id="EN-US_TOPIC_0000001764675138__ac4c814ddf6754cd98d7ea10b7d3471f4">IF NOT EXISTS</strong><p id="EN-US_TOPIC_0000001764675138__a907e52a2875c4303b296eb9192898111">If <strong id="EN-US_TOPIC_0000001764675138__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_0000001764675138__lcacb45adeaab4dc690fff7670c8f1068"><strong id="EN-US_TOPIC_0000001764675138__accc4048091f74784a4329b2cff3870a2">table_name</strong><p id="EN-US_TOPIC_0000001764675138__a69479c547933434eb9ef0c547a2090dc">Specifies the name of the table to be created.</p>
<p id="EN-US_TOPIC_0000001764675138__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_0000001764675138__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_0000001764675138__l9617e926aec24a75b2c2472789705e99"><strong id="EN-US_TOPIC_0000001764675138__a114c6e26ec294f52a3fd16a29bb91ae6">column_name</strong><p id="EN-US_TOPIC_0000001764675138__a77a2b66dd4fa4e4099ffaa5c2233ffdb">Specifies the name of a column to be created in the new table.</p>
<p id="EN-US_TOPIC_0000001764675138__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_0000001764675138__l34f1a566739c48b4be821481538f5b81"><strong id="EN-US_TOPIC_0000001764675138__abf296480d6a249bfb6cf296a54adef2a">data_type</strong><p id="EN-US_TOPIC_0000001764675138__a2f57ce2d5cdb4c4d82556493aca949db">Specifies the data type of the column.</p>
<div class="note" id="EN-US_TOPIC_0000001764675138__note57291658143719"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="EN-US_TOPIC_0000001764675138__p20729195803714">In a database 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_0000001764675138__leae9e2e4c3b24cbc840a63fac26967bf"><strong id="EN-US_TOPIC_0000001764675138__abb452499ba06468a92aee28041dc612b">compress_mode</strong><p id="EN-US_TOPIC_0000001764675138__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_0000001764675138__a1d9fc64d6a0c41129e29c2739c6cd491">Value range: DELTA, PREFIX, DICTIONARY, NUMSTR, NOCOMPRESS</p>
</li><li id="EN-US_TOPIC_0000001764675138__l8833e8a37d8847e6a084aaa436a4785a"><strong id="EN-US_TOPIC_0000001764675138__a33d7e7f0a2f7440da6ad45191a997bc3">COLLATE collation</strong><p id="EN-US_TOPIC_0000001764675138__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_0000001764675138__l9f8eff5559b14ec7a69c0966fd7ebeae"><strong id="EN-US_TOPIC_0000001764675138__aac04cbe8532f40a4a75f915be05075d6">LIKE source_table [ like_option ... ]</strong><p id="EN-US_TOPIC_0000001764675138__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_0000001764675138__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_0000001764675138__a82dec42153404e0aa7bd8292fb41bad2">Columns and constraints copied by <strong id="EN-US_TOPIC_0000001764675138__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_0000001764675138__b617509951783">LIKE</strong> clause, an error is reported.</p>
<ul id="EN-US_TOPIC_0000001764675138__u4ceb5f7c91f34aec96c9096ba1b9e166"><li id="EN-US_TOPIC_0000001764675138__l8ec43792af1e4657821db87fa1ee418b">The default expressions or the <strong id="EN-US_TOPIC_0000001764675138__b125051445184512">ON UPDATE</strong> expressions are copied from the source table to the new table only if <strong id="EN-US_TOPIC_0000001764675138__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_0000001764675138__b15257491783">NULL</strong>.</li><li id="EN-US_TOPIC_0000001764675138__la1710617a89e4f4facb17d14d7bd42ff">The <strong id="EN-US_TOPIC_0000001764675138__b84235270622331">CHECK</strong> constraints are copied from the source table to the new table only when <strong id="EN-US_TOPIC_0000001764675138__b18927170822323">INCLUDING CONSTRAINTS</strong> is specified. Other types of constraints are never copied to the new table. <strong id="EN-US_TOPIC_0000001764675138__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_0000001764675138__l168e3a37406543daaca47673b43bcb21">Any indexes on the source table will not be created on the new table, unless the <strong id="EN-US_TOPIC_0000001764675138__en-us_topic_0058965796_b84235270611020">INCLUDING INDEXES</strong> clause is specified.</li><li id="EN-US_TOPIC_0000001764675138__l7f54e2e77bfb4e84a46e60847e15a9e8">STORAGE settings for the copied column definitions are copied only if <strong id="EN-US_TOPIC_0000001764675138__b84235270611028">INCLUDING STORAGE</strong> is specified. The default behavior is to exclude <strong id="EN-US_TOPIC_0000001764675138__b84235270611036">STORAGE</strong> settings.</li><li id="EN-US_TOPIC_0000001764675138__l00432959a35c499cbb32921fbeb51566">If <strong id="EN-US_TOPIC_0000001764675138__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_0000001764675138__l78294dafebc644a399f057babb13af76">If <strong id="EN-US_TOPIC_0000001764675138__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_0000001764675138__b15238226115318">PARTITION BY</strong> clause. The default behavior is to exclude partition definition of the source table.</li><li id="EN-US_TOPIC_0000001764675138__li056717401121">If <strong id="EN-US_TOPIC_0000001764675138__b84235270611052">INCLUDING RELOPTIONS</strong> is specified, the storage parameter (<strong id="EN-US_TOPIC_0000001764675138__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_0000001764675138__note1553119400128"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="EN-US_TOPIC_0000001764675138__p10531940161217"><strong id="EN-US_TOPIC_0000001764675138__b1310505010364">PERIOD</strong> and <strong id="EN-US_TOPIC_0000001764675138__b112811953113613">TTL</strong> in the <strong id="EN-US_TOPIC_0000001764675138__b188961759133610">WITH</strong> clause are partition-related parameters. <strong id="EN-US_TOPIC_0000001764675138__b82092249378">LIKE INCLUDING RELOPTIONS</strong> will not be copied to the new table. To copy <strong id="EN-US_TOPIC_0000001764675138__b1173833444010">LIKE INCLUDING RELOPTIONS</strong>, use <strong id="EN-US_TOPIC_0000001764675138__b18168154134014">INCLUDING PARTITION</strong>.</p>
</div></div>
</li><li id="EN-US_TOPIC_0000001764675138__l5b63aefd78b048608255c5d45e1f2e59">If <strong id="EN-US_TOPIC_0000001764675138__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_0000001764675138__b84235270611111">DISTRIBUTE BY</strong> clause. The default behavior is to exclude distribution information of the source table.</li><li id="EN-US_TOPIC_0000001764675138__li640611365015">If <strong id="EN-US_TOPIC_0000001764675138__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_0000001764675138__l10d4feca9efc478e8f8cdd64578db5ea"><strong id="EN-US_TOPIC_0000001764675138__b84235270622158">INCLUDING ALL</strong> contains the meaning of <strong id="EN-US_TOPIC_0000001764675138__b842352706221511">INCLUDING DEFAULTS</strong>, <strong id="EN-US_TOPIC_0000001764675138__b842352706221515">INCLUDING CONSTRAINTS</strong>, <strong id="EN-US_TOPIC_0000001764675138__b842352706221518">INCLUDING INDEXES</strong>, <strong id="EN-US_TOPIC_0000001764675138__b842352706221522">INCLUDING STORAGE</strong>, <strong id="EN-US_TOPIC_0000001764675138__b842352706221524">INCLUDING COMMENTS</strong>, <strong id="EN-US_TOPIC_0000001764675138__b842352706221528">INCLUDING PARTITION</strong>, <strong id="EN-US_TOPIC_0000001764675138__b842352706221530">INCLUDING RELOPTIONS</strong>, <strong id="EN-US_TOPIC_0000001764675138__b41672044105610">INCLUDING DISTRIBUTION</strong>, and <strong id="EN-US_TOPIC_0000001764675138__b171901013145718">INCLUDING DROPCOLUMNS</strong>. </li><li id="EN-US_TOPIC_0000001764675138__li153101438375">If EXCLUDING is specified, the specified parameters are not included.</li><li id="EN-US_TOPIC_0000001764675138__li37468519720">For an OBS multi-temperature table, all partitions of the new table are local hot partitions after <strong id="EN-US_TOPIC_0000001764675138__b17657113413254">INCLUDING PARTITION</strong> is specified.</li></ul>
<div class="notice" id="EN-US_TOPIC_0000001764675138__note114471820913"><span class="noticetitle"><img src="public_sys-resources/notice_3.0-en-us.png"> </span><div class="noticebody"><ul id="EN-US_TOPIC_0000001764675138__ul1245114202012"><li id="EN-US_TOPIC_0000001764675138__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_0000001764675138__b8639141710">CREATE SEQUENCE...</strong> <strong id="EN-US_TOPIC_0000001764675138__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_0000001764675138__b164482944810">OWNED BY</strong>) and set a column in the source table to this sequence.</li><li id="EN-US_TOPIC_0000001764675138__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_0000001764675138__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_0000001764675138__l4af34b084f7c4b1a96c37516810dc04d"><strong id="EN-US_TOPIC_0000001764675138__a2761a7089649476bbf0299a61e9f23da">WITH ( { storage_parameter = value } [, ... ] )</strong><p id="EN-US_TOPIC_0000001764675138__ac10e4ce413a0489b927941d4d9e1e18e">Specifies an optional storage parameter for a table or an index.</p>
<div class="note" id="EN-US_TOPIC_0000001764675138__nb4e9ac710039431c818878c9ef231cb5"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="EN-US_TOPIC_0000001764675138__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_0000001764675138__aa2fd5d776c8845a8ad24a34d286c09c7">The description of parameters is as follows:</p>
<ul id="EN-US_TOPIC_0000001764675138__u3170c562e94a492897636fbfcbcfb2b5"><li id="EN-US_TOPIC_0000001764675138__l24d1225dcddd4f08b059e91853936932">FILLFACTOR<p id="EN-US_TOPIC_0000001764675138__ac011eb472f2141c6834cf6a606c3d299"><a name="EN-US_TOPIC_0000001764675138__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_0000001764675138__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_0000001764675138__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_0000001764675138__a0a5934b8d9434bf489d67f14cc27868b">Value range: 10 to 100</p>
</li><li id="EN-US_TOPIC_0000001764675138__le578deaf72b64b2fba7c1ae284e30b15">ORIENTATION<p id="EN-US_TOPIC_0000001764675138__a255bea141fad4ab3bd9d37c304c3a315"><a name="EN-US_TOPIC_0000001764675138__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_0000001764675138__a070516800fa944bfae754bd3a5e3ccc7">Valid value:</p>
<ul id="EN-US_TOPIC_0000001764675138__ua9832dec6c604f25a00e3a52cac1d7d9"><li id="EN-US_TOPIC_0000001764675138__l2c49a5929a3b47a59a24f5c8baaca843"><strong id="EN-US_TOPIC_0000001764675138__b842352706221833">ROW</strong> indicates that table data is stored in rows.<p id="EN-US_TOPIC_0000001764675138__a66f4ae52ca0d4df3aff0f52ed23f6c81"><strong id="EN-US_TOPIC_0000001764675138__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_0000001764675138__le28dcda0112348209ae14aa1b9a6a2ca"><strong id="EN-US_TOPIC_0000001764675138__b0608142420116">COLUMN</strong> indicates that the data is stored in columns.<p id="EN-US_TOPIC_0000001764675138__a28561aef4f9f4a91897abd56177c3de9"><strong id="EN-US_TOPIC_0000001764675138__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_0000001764675138__p166641755203517">Default value: <strong id="EN-US_TOPIC_0000001764675138__b5217113974615">ROW</strong> (row-store)</p>
</li><li id="EN-US_TOPIC_0000001764675138__l770ea1d44c9f44bf8d17c8cb0a26bac6">COMPRESSION<p id="EN-US_TOPIC_0000001764675138__ac2dfb496dc8e4ce6a291fd888995f6e9"><a name="EN-US_TOPIC_0000001764675138__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_0000001764675138__ac519dc54e9f84c90b3c8cd208f43c883">Valid value:</p>
<p id="EN-US_TOPIC_0000001764675138__p94411821419">The valid values for column-store tables are <strong id="EN-US_TOPIC_0000001764675138__b11212143744315">YES</strong>/<strong id="EN-US_TOPIC_0000001764675138__b17618738204312">NO</strong> and <strong id="EN-US_TOPIC_0000001764675138__b103841140134312">LOW</strong>/<strong id="EN-US_TOPIC_0000001764675138__b1144654317433">MIDDLE</strong>/<strong id="EN-US_TOPIC_0000001764675138__b1846219458430">HIGH</strong>, and the default is <strong id="EN-US_TOPIC_0000001764675138__b842352706112332">LOW</strong>. When this parameter is set to <strong id="EN-US_TOPIC_0000001764675138__b54612964232021">YES</strong>, the compression level is <strong id="EN-US_TOPIC_0000001764675138__b71405688532021">LOW</strong> by default.</p>
<div class="p" id="EN-US_TOPIC_0000001764675138__p1568712116148"><div class="note" id="EN-US_TOPIC_0000001764675138__note141418320435"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><ul id="EN-US_TOPIC_0000001764675138__ul82263435309"><li id="EN-US_TOPIC_0000001764675138__li39874611479">Currently, row-store table compression is not supported.</li><li id="EN-US_TOPIC_0000001764675138__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_0000001764675138__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_0000001764675138__p2810714202814"><span id="EN-US_TOPIC_0000001764675138__text621906510">GaussDB(DWS)</span> provides the following compression algorithms:</p>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="EN-US_TOPIC_0000001764675138__table340453215226" frame="border" border="1" rules="all"><caption><b>Table 2 </b>Compression algorithms for column-based storage</caption><thead align="left"><tr id="EN-US_TOPIC_0000001764675138__row7405123242212"><th align="left" class="cellrowborder" valign="top" width="20%" id="mcps1.3.9.2.11.5.3.6.2.5.1.1"><p id="EN-US_TOPIC_0000001764675138__p19405232182210">COMPRESSION</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="26%" id="mcps1.3.9.2.11.5.3.6.2.5.1.2"><p id="EN-US_TOPIC_0000001764675138__p740553213223">NUMERIC</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="26%" id="mcps1.3.9.2.11.5.3.6.2.5.1.3"><p id="EN-US_TOPIC_0000001764675138__p9405232172213">STRING</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="28.000000000000004%" id="mcps1.3.9.2.11.5.3.6.2.5.1.4"><p id="EN-US_TOPIC_0000001764675138__p640533242216">INT</p>
</th>
</tr>
</thead>
<tbody><tr id="EN-US_TOPIC_0000001764675138__row7406332162215"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.9.2.11.5.3.6.2.5.1.1 "><p id="EN-US_TOPIC_0000001764675138__p24060329223">LOW</p>
</td>
<td class="cellrowborder" valign="top" width="26%" headers="mcps1.3.9.2.11.5.3.6.2.5.1.2 "><p id="EN-US_TOPIC_0000001764675138__p84061732142214">Delta compression + RLE compression</p>
</td>
<td class="cellrowborder" valign="top" width="26%" headers="mcps1.3.9.2.11.5.3.6.2.5.1.3 "><p id="EN-US_TOPIC_0000001764675138__p194066323225">LZ4 compression</p>
</td>
<td class="cellrowborder" valign="top" width="28.000000000000004%" headers="mcps1.3.9.2.11.5.3.6.2.5.1.4 "><p id="EN-US_TOPIC_0000001764675138__p740614326221">Delta compression (RLE is optional.)</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001764675138__row11406133217228"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.9.2.11.5.3.6.2.5.1.1 "><p id="EN-US_TOPIC_0000001764675138__p3406103242218">MIDDLE</p>
</td>
<td class="cellrowborder" valign="top" width="26%" headers="mcps1.3.9.2.11.5.3.6.2.5.1.2 "><p id="EN-US_TOPIC_0000001764675138__p1140683219229">Delta compression + RLE compression + LZ4 compression</p>
</td>
<td class="cellrowborder" valign="top" width="26%" headers="mcps1.3.9.2.11.5.3.6.2.5.1.3 "><p id="EN-US_TOPIC_0000001764675138__p640623292214">dict compression or LZ4 compression</p>
</td>
<td class="cellrowborder" valign="top" width="28.000000000000004%" headers="mcps1.3.9.2.11.5.3.6.2.5.1.4 "><p id="EN-US_TOPIC_0000001764675138__p1340653292210">Delta compression or LZ4 compression (RLE is optional)</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001764675138__row84061932202218"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.9.2.11.5.3.6.2.5.1.1 "><p id="EN-US_TOPIC_0000001764675138__p340673252211">HIGH</p>
</td>
<td class="cellrowborder" valign="top" width="26%" headers="mcps1.3.9.2.11.5.3.6.2.5.1.2 "><p id="EN-US_TOPIC_0000001764675138__p11407103214224">Delta compression + RLE compression + zlib compression</p>
</td>
<td class="cellrowborder" valign="top" width="26%" headers="mcps1.3.9.2.11.5.3.6.2.5.1.3 "><p id="EN-US_TOPIC_0000001764675138__p164071532152219">dict compression or zlib compression</p>
</td>
<td class="cellrowborder" valign="top" width="28.000000000000004%" headers="mcps1.3.9.2.11.5.3.6.2.5.1.4 "><p id="EN-US_TOPIC_0000001764675138__p340717323228">Delta compression or zlib compression (RLE is optional)</p>
</td>
</tr>
</tbody>
</table>
</div>
</li><li id="EN-US_TOPIC_0000001764675138__l677fdcd156914cc8bdaaa4713c333b34">COMPRESSLEVEL<p id="EN-US_TOPIC_0000001764675138__a58c1b12b31464cfba45d9ce40aa51f4e"><a name="EN-US_TOPIC_0000001764675138__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_0000001764675138__p7999121210374">Value range: 03.</p>
<p id="EN-US_TOPIC_0000001764675138__a50ebabc106f1448c95d6b1c810e1aa48">Default value: <strong id="EN-US_TOPIC_0000001764675138__b17938264857024">0</strong></p>
</li><li id="EN-US_TOPIC_0000001764675138__en-us_topic_0000001254211977_li11305165613216">TTL<p id="EN-US_TOPIC_0000001764675138__en-us_topic_0000001254211977_p143051956193219"><a name="EN-US_TOPIC_0000001764675138__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_0000001764675138__en-us_topic_0000001254211977_p430514567322">Value range: 1 hour100 years</p>
</li><li id="EN-US_TOPIC_0000001764675138__en-us_topic_0000001254211977_li1562417123317">PERIOD<p id="EN-US_TOPIC_0000001764675138__en-us_topic_0000001254211977_p1256251719339"><a name="EN-US_TOPIC_0000001764675138__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_0000001764675138__b1685311303523">TTL</strong> has been configured, <strong id="EN-US_TOPIC_0000001764675138__b11853163025220">PERIOD</strong> cannot be greater than <strong id="EN-US_TOPIC_0000001764675138__b685353025217">TTL</strong>.</p>
<p id="EN-US_TOPIC_0000001764675138__p14517737792">Value range: 1 hour100 years</p>
<p id="EN-US_TOPIC_0000001764675138__en-us_topic_0000001254211977_p17562017193310">Default value: 1 day</p>
</li><li id="EN-US_TOPIC_0000001764675138__lff6a2288b8ec472993acbcf2b2d7c984">MAX_BATCHROW<p id="EN-US_TOPIC_0000001764675138__a55c284d6c0c843e0861506326473d715"><a name="EN-US_TOPIC_0000001764675138__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_0000001764675138__p59361644122913">Value range: 10000 to 60000</p>
<p id="EN-US_TOPIC_0000001764675138__af17457566b404c3aa62bfef662c9fba3">Default value: 60,000</p>
</li><li id="EN-US_TOPIC_0000001764675138__l09d7b9048bcd4612a7e3529d8597419f">PARTIAL_CLUSTER_ROWS<p id="EN-US_TOPIC_0000001764675138__ad566fbb5176e467cbcaafdd158c25afc"><a name="EN-US_TOPIC_0000001764675138__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_0000001764675138__a743957d47ee549909ca4d0ebc5fb5ed4">Value range: 600000 to 2147483647</p>
<p id="EN-US_TOPIC_0000001764675138__p362613312546">Default value: 4,200,000</p>
</li><li id="EN-US_TOPIC_0000001764675138__li9433942012">time_format<p id="EN-US_TOPIC_0000001764675138__p239134542910"><a name="EN-US_TOPIC_0000001764675138__li9433942012"></a><a name="li9433942012"></a>You can use auto-increment and decrement partitions for <strong id="EN-US_TOPIC_0000001764675138__b11655104565717">INT4</strong>, <strong id="EN-US_TOPIC_0000001764675138__b62087505571">INT8</strong>, <strong id="EN-US_TOPIC_0000001764675138__b115225210571">VARCHAR</strong>, and <strong id="EN-US_TOPIC_0000001764675138__b1199465335710">TEXT</strong> columns, which are commonly used for storing time-related data. The <strong id="EN-US_TOPIC_0000001764675138__b934103655817">time_format</strong> option is applicable only when the partition key is <strong id="EN-US_TOPIC_0000001764675138__b1128413427581">INT4</strong>, <strong id="EN-US_TOPIC_0000001764675138__b42314448588">INT8</strong>, <strong id="EN-US_TOPIC_0000001764675138__b640844765814">VARCHAR</strong>, or <strong id="EN-US_TOPIC_0000001764675138__b1569964935810">TEXT</strong> and a period is specified. This is supported only by clusters of version 9.1.0.200 or later.</p>
<ol id="EN-US_TOPIC_0000001764675138__ol1567154214292"><li id="EN-US_TOPIC_0000001764675138__li377083516373">The value of <strong id="EN-US_TOPIC_0000001764675138__b10229125471211">time_format</strong> must comply with the PostgreSQL specifications, for example, <strong id="EN-US_TOPIC_0000001764675138__b2230185461210">yyyymmdd</strong>.</li><li id="EN-US_TOPIC_0000001764675138__li106711542192920">Restrictions on <strong id="EN-US_TOPIC_0000001764675138__b154239353110">time_format</strong> differ by partition key type.<p id="EN-US_TOPIC_0000001764675138__p12671184219294"><strong id="EN-US_TOPIC_0000001764675138__b151281671724">VARCHAR</strong>/<strong id="EN-US_TOPIC_0000001764675138__b13111131118214">TEXT</strong>:</p>
<ul id="EN-US_TOPIC_0000001764675138__ul11917155510331"><li id="EN-US_TOPIC_0000001764675138__li8917555113320">The precision can be accurate to seconds.</li><li id="EN-US_TOPIC_0000001764675138__li1791718554333">The value cannot contain letters, for example, <strong id="EN-US_TOPIC_0000001764675138__b107411535136">month</strong>, <strong id="EN-US_TOPIC_0000001764675138__b1774216320136">am</strong>, and <strong id="EN-US_TOPIC_0000001764675138__b137421439132">pm</strong>.</li><li id="EN-US_TOPIC_0000001764675138__li1691720558338">The time must be arranged in descending order, for example, year, month, day, hour, minute, and second.</li></ul>
<p id="EN-US_TOPIC_0000001764675138__p19671154211294"><strong id="EN-US_TOPIC_0000001764675138__b193443261927">INT4</strong>/<strong id="EN-US_TOPIC_0000001764675138__b511819287210">INT8</strong>:</p>
<ul id="EN-US_TOPIC_0000001764675138__ul91121344133411"><li id="EN-US_TOPIC_0000001764675138__li6112184414340">The precision can be accurate to hours.</li><li id="EN-US_TOPIC_0000001764675138__li8112204412348">The value can contain only <strong id="EN-US_TOPIC_0000001764675138__b537911401922">Y</strong>, <strong id="EN-US_TOPIC_0000001764675138__b1449420441825">M</strong>, <strong id="EN-US_TOPIC_0000001764675138__b159431345122">D</strong>, and <strong id="EN-US_TOPIC_0000001764675138__b156017489218">HH24</strong>.</li><li id="EN-US_TOPIC_0000001764675138__li151127446344">The time must be arranged in descending order, for example, year, month, day, and hour.</li></ul>
</li><li id="EN-US_TOPIC_0000001764675138__li240712115350"><strong id="EN-US_TOPIC_0000001764675138__b1328812142313">ALTER</strong> restrictions:<ul id="EN-US_TOPIC_0000001764675138__ul04051259113517"><li id="EN-US_TOPIC_0000001764675138__li140510596359">The set operation is not supported.</li><li id="EN-US_TOPIC_0000001764675138__li1940595903512">When period is reset (indicating that automatic partitioning is disabled and a message is displayed), you can reset this option.</li></ul>
</li></ol>
</li><li id="EN-US_TOPIC_0000001764675138__li2613194271216">enable_delta<p id="EN-US_TOPIC_0000001764675138__p1761394219122"><a name="EN-US_TOPIC_0000001764675138__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. If <strong id="EN-US_TOPIC_0000001764675138__b7823311947">COLVERSION</strong> is set to <strong id="EN-US_TOPIC_0000001764675138__b12824161117414">3.0</strong>, <strong id="EN-US_TOPIC_0000001764675138__b1282413112043">enable_delta</strong> cannot be turned on because this parameter is not supported by V3 tables.</p>
<p id="EN-US_TOPIC_0000001764675138__p10705181944518">Using column-store tables with delta tables is not recommended. This may cause disk bloat and performance deterioration due to delayed merge.</p>
<p id="EN-US_TOPIC_0000001764675138__p561354210126">Default value: <strong id="EN-US_TOPIC_0000001764675138__b18489181710210">off</strong></p>
</li><li id="EN-US_TOPIC_0000001764675138__li4236202164514">enable_hstore<p id="EN-US_TOPIC_0000001764675138__p22361025458"><a name="EN-US_TOPIC_0000001764675138__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. If <strong id="EN-US_TOPIC_0000001764675138__b219714329219">COLVERSION</strong> is set to <strong id="EN-US_TOPIC_0000001764675138__b1619817321424">3.0</strong>, <strong id="EN-US_TOPIC_0000001764675138__b9199132623">enable_delta</strong> cannot be turned on because this parameter is not supported by V3 tables.</p>
<p id="EN-US_TOPIC_0000001764675138__p13236520457">Default value: <strong id="EN-US_TOPIC_0000001764675138__b1255986730">off</strong></p>
<div class="note" id="EN-US_TOPIC_0000001764675138__note1034095181611"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="EN-US_TOPIC_0000001764675138__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_0000001764675138__p193173119500">Set <strong id="EN-US_TOPIC_0000001764675138__b16841155091120">autovacuum</strong> to <strong id="EN-US_TOPIC_0000001764675138__b3471219141211">on</strong>, <strong id="EN-US_TOPIC_0000001764675138__b6132337121216">autovacuum_max_workers</strong> to <strong id="EN-US_TOPIC_0000001764675138__b5515203815120">6</strong>, and <strong id="EN-US_TOPIC_0000001764675138__b177931731156">autovacuum_max_workers_hstore</strong> to <strong id="EN-US_TOPIC_0000001764675138__b2563203816157">3</strong>.</p>
</div></div>
</li><li id="EN-US_TOPIC_0000001764675138__li1731172013545">enable_disaster_cstore<p id="EN-US_TOPIC_0000001764675138__p431132017546"><a name="EN-US_TOPIC_0000001764675138__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_0000001764675138__b879485915243">true</strong> if <strong id="EN-US_TOPIC_0000001764675138__b779463102518">enable_hstore</strong> is <strong id="EN-US_TOPIC_0000001764675138__b579885122516">true</strong>. This parameter is supported by version 8.2.0.100 or later clusters.</p>
</li><li id="EN-US_TOPIC_0000001764675138__li1083514691112">fine_disaster_table_role<p id="EN-US_TOPIC_0000001764675138__p11451410308"><a name="EN-US_TOPIC_0000001764675138__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_0000001764675138__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_0000001764675138__b144388562914">true</strong> only when the <strong id="EN-US_TOPIC_0000001764675138__b10620101392818">enable_disaster_cstore</strong> parameter has been set to <strong id="EN-US_TOPIC_0000001764675138__b17925112752818">true</strong>.</p>
<p id="EN-US_TOPIC_0000001764675138__p1791385616136">Valid value:</p>
<ul id="EN-US_TOPIC_0000001764675138__ul149131756111310"><li id="EN-US_TOPIC_0000001764675138__li119131563136"><strong id="EN-US_TOPIC_0000001764675138__b147841420292">primary</strong>: Specifies the primary fine-grained DR table.</li><li id="EN-US_TOPIC_0000001764675138__li891375691315"><strong id="EN-US_TOPIC_0000001764675138__b452891792911">standby</strong>: Specifies the standby fine-grained DR table.</li></ul>
</li><li id="EN-US_TOPIC_0000001764675138__l70caac449c624b2aafb1efe4b6ba69f7">DELTAROW_THRESHOLD<p id="EN-US_TOPIC_0000001764675138__a405e51516cf94d89b2ecfe461f1cdfd8"><a name="EN-US_TOPIC_0000001764675138__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_0000001764675138__b83454182414">enable_delta</strong> table parameter is set to <strong id="EN-US_TOPIC_0000001764675138__b147114391302">on</strong>. The parameter is only valid for column-store tables.</p>
<p id="EN-US_TOPIC_0000001764675138__p121507813619">Value range: 0 to 60000</p>
<p id="EN-US_TOPIC_0000001764675138__aad22c617d71142a991d7fc027213e78c"><strong id="EN-US_TOPIC_0000001764675138__b11214174267025">Default value</strong>: <strong id="EN-US_TOPIC_0000001764675138__b17621666157025">6000</strong></p>
</li><li id="EN-US_TOPIC_0000001764675138__li650019179418">COLVERSION<p id="EN-US_TOPIC_0000001764675138__p35006179418"><a name="EN-US_TOPIC_0000001764675138__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_0000001764675138__p1850016171446">Valid value:</p>
<p id="EN-US_TOPIC_0000001764675138__p1050014175413"><strong id="EN-US_TOPIC_0000001764675138__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_0000001764675138__b198832225512">relfilenode.C1.0</strong>, <strong id="EN-US_TOPIC_0000001764675138__b66763253515">relfilenode.C2.0</strong>, <strong id="EN-US_TOPIC_0000001764675138__b1787492815518">relfilenode.C3.0</strong>, or similar.</p>
<p id="EN-US_TOPIC_0000001764675138__p1250012171411"><strong id="EN-US_TOPIC_0000001764675138__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_0000001764675138__b768315588341">relfilenode.C1.0</strong>.</p>
<p id="EN-US_TOPIC_0000001764675138__p13967852192213"><strong id="EN-US_TOPIC_0000001764675138__b1425194511516">3.0</strong>: Each column of a column-store table is stored in a file. The file is stored in the OBS file system and named <strong id="EN-US_TOPIC_0000001764675138__b725154571514">C1_fileid.0</strong>.</p>
<p id="EN-US_TOPIC_0000001764675138__p19500917545">Default value: The default value for the storage-compute coupled version is 2.0, while for the storage-compute decoupling version, it is 3.0.</p>
<p id="EN-US_TOPIC_0000001764675138__p135079255718">The value of <strong id="EN-US_TOPIC_0000001764675138__b1612615774010">COLVERSION</strong> can only be set to <strong id="EN-US_TOPIC_0000001764675138__b550718171406">2.0</strong> for OBS multi-temperature tables.</p>
<div class="note" id="EN-US_TOPIC_0000001764675138__note57078250414"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><ul id="EN-US_TOPIC_0000001764675138__ul11967181133"><li id="EN-US_TOPIC_0000001764675138__li21961418181314">For clusters of version 8.1.0, the default value of this parameter is <strong id="EN-US_TOPIC_0000001764675138__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_0000001764675138__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_0000001764675138__b7176309217025">1.0</strong> to <strong id="EN-US_TOPIC_0000001764675138__b19271558107025">2.0</strong>.</li><li id="EN-US_TOPIC_0000001764675138__li3196918201311">When creating a column-store table, set <strong id="EN-US_TOPIC_0000001764675138__b6046088717025">COLVERSION</strong> to <strong id="EN-US_TOPIC_0000001764675138__b21307955457025">2.0</strong>. Compared with the <strong id="EN-US_TOPIC_0000001764675138__b6757197257025">1.0</strong> storage format, the performance is significantly improved:<ul id="EN-US_TOPIC_0000001764675138__ul109871941143011"><li id="EN-US_TOPIC_0000001764675138__li198784119308">The time required for creating a column-store wide table is significantly reduced.</li><li id="EN-US_TOPIC_0000001764675138__li7987241153019">In the Roach data backup scenario, the backup time is significantly reduced.</li><li id="EN-US_TOPIC_0000001764675138__li49875412305">The build and catch up time is greatly reduced.</li><li id="EN-US_TOPIC_0000001764675138__li1898724113015">The occupied disk space decreases significantly.</li></ul>
</li><li id="EN-US_TOPIC_0000001764675138__en-us_topic_0000001342465185_li176508438104">The storage-compute decoupling 3.0 version is compatible with all column-store versions. When creating a table, you need to explicitly specify the value of <strong id="EN-US_TOPIC_0000001764675138__b152721049182714">colversion</strong> (<strong id="EN-US_TOPIC_0000001764675138__b112721749142710">1.0</strong>, <strong id="EN-US_TOPIC_0000001764675138__b82720496272">2.0</strong>, or <strong id="EN-US_TOPIC_0000001764675138__b19273144932717">3.0</strong>). If <strong id="EN-US_TOPIC_0000001764675138__b14464153102718">colversion</strong> is set to <strong id="EN-US_TOPIC_0000001764675138__b18465195322717">3.0</strong>, a table in decoupled storage and computing mode is created. If <strong id="EN-US_TOPIC_0000001764675138__b246555322719">colversion</strong> is not explicitly specified, a column-store table of version 3.0 is created by default. When creating a table with decoupled storage and compute nodes, set <strong id="EN-US_TOPIC_0000001764675138__b1135420179292">colversion</strong> to <strong id="EN-US_TOPIC_0000001764675138__b1423462019293">3.0</strong> and set <strong id="EN-US_TOPIC_0000001764675138__b6735172382911">orientation</strong> to <strong id="EN-US_TOPIC_0000001764675138__b1423927202917">column</strong>.</li><li id="EN-US_TOPIC_0000001764675138__en-us_topic_0000001342465185_li6349195571417">V3 storage-compute decoupling tables do not support colversion switching using <strong id="EN-US_TOPIC_0000001764675138__b299711172310">ALTER TABLE</strong>, for example, from 2.0 to 3.0.</li></ul>
</div></div>
</li><li id="EN-US_TOPIC_0000001764675138__li280884617368">analyze_mode<p id="EN-US_TOPIC_0000001764675138__p10808184611361"><a name="EN-US_TOPIC_0000001764675138__li280884617368"></a><a name="li280884617368"></a>Specifies the mode of table-level auto-analyze.</p>
<p id="EN-US_TOPIC_0000001764675138__p11808146113620">Valid value:</p>
<ul id="EN-US_TOPIC_0000001764675138__ul124501408445"><li id="EN-US_TOPIC_0000001764675138__li1945016013448"><strong id="EN-US_TOPIC_0000001764675138__b14787612115718">frozen</strong>: disables all <strong id="EN-US_TOPIC_0000001764675138__b1577911511707">ANALYZE</strong> operations (dynamic sampling can still be triggered when no statistics are collected).</li><li id="EN-US_TOPIC_0000001764675138__li321102214441"><strong id="EN-US_TOPIC_0000001764675138__b5784125945919">backend</strong>: allows only <strong id="EN-US_TOPIC_0000001764675138__b1741133817716">ANALYZE</strong> triggered by <strong id="EN-US_TOPIC_0000001764675138__b65241819987">AUTOVACUUM</strong> polling.</li><li id="EN-US_TOPIC_0000001764675138__li834013241448"><strong id="EN-US_TOPIC_0000001764675138__b1272611241680">runtime</strong>: allows only runtime <strong id="EN-US_TOPIC_0000001764675138__b1258717416817">ANALYZE</strong> triggered by the optimizer.</li><li id="EN-US_TOPIC_0000001764675138__li141931812164419"><strong id="EN-US_TOPIC_0000001764675138__b3549195112811">all</strong>: Both backend and runtime <strong id="EN-US_TOPIC_0000001764675138__b165111130290">AUTO-ANALYZE</strong> can be triggered.</li></ul>
<p id="EN-US_TOPIC_0000001764675138__p1172410511374">Default value: <strong id="EN-US_TOPIC_0000001764675138__b4819996567025">all</strong></p>
</li><li id="EN-US_TOPIC_0000001764675138__li5111124862519">incremental_analyze<p id="EN-US_TOPIC_0000001764675138__p8111174842511"><a name="EN-US_TOPIC_0000001764675138__li5111124862519"></a><a name="li5111124862519"></a>Specifies whether to enable the incremental analyze mode for partitioned tables. This parameter is valid only for partitioned tables and cannot be set for replicated tables. This is supported only by clusters of version 9.1.0.100 or later.</p>
<p id="EN-US_TOPIC_0000001764675138__p71128481255">The default value is <strong id="EN-US_TOPIC_0000001764675138__b191266398337">false</strong>.</p>
</li><li id="EN-US_TOPIC_0000001764675138__li32608317479">SKIP_FPI_HINT<p id="EN-US_TOPIC_0000001764675138__p185568515461"><a name="EN-US_TOPIC_0000001764675138__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_0000001764675138__p3172164012188">Default value: <strong id="EN-US_TOPIC_0000001764675138__b94410361223">false</strong><div class="note" id="EN-US_TOPIC_0000001764675138__note177211636121818"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="EN-US_TOPIC_0000001764675138__p1721193631819">If <strong id="EN-US_TOPIC_0000001764675138__b1792110392228">SKIP_FPI_HINT</strong> is set to <strong id="EN-US_TOPIC_0000001764675138__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_0000001764675138__li137045328105">on_commit_preserve_rows<p id="EN-US_TOPIC_0000001764675138__p959590111210"><a name="EN-US_TOPIC_0000001764675138__li137045328105"></a><a name="li137045328105"></a>It is similar to <strong id="EN-US_TOPIC_0000001764675138__b7162182414363">ON COMMIT { PRESERVE ROWS | DELETE ROWS }</strong>. The two parameters cannot be specified at the same time. This parameter is used only for global temporary tables.</p>
<p id="EN-US_TOPIC_0000001764675138__p1214105231117">Default value: <strong id="EN-US_TOPIC_0000001764675138__b1698093426103716">true</strong></p>
</li><li id="EN-US_TOPIC_0000001764675138__li19341172911552">enable_column_autovacuum_garbage<p id="EN-US_TOPIC_0000001764675138__p13709132310477"><a name="EN-US_TOPIC_0000001764675138__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_0000001764675138__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_0000001764675138__b780116157393">off</strong> to avoid this problem.</p>
<p id="EN-US_TOPIC_0000001764675138__p16341202955520">Default value: <strong id="EN-US_TOPIC_0000001764675138__b1819285281103716">true</strong></p>
</li><li id="EN-US_TOPIC_0000001764675138__li072511533273">secondary_part_column<p id="EN-US_TOPIC_0000001764675138__p5725135312714"><a name="EN-US_TOPIC_0000001764675138__li072511533273"></a><a name="li072511533273"></a>Specifies the name of a level-2 partition column in a column-store table. Only one column can be specified as the level-2 partition column. This parameter applies only to H-Store column-store tables. This parameter is supported only by clusters of version 8.3.0 or later.</p>
<div class="note" id="EN-US_TOPIC_0000001764675138__note197255533275"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><ul id="EN-US_TOPIC_0000001764675138__ul9661132315177"><li id="EN-US_TOPIC_0000001764675138__li146616237179">The column specified as a level-2 partition column cannot be deleted or modified.</li><li id="EN-US_TOPIC_0000001764675138__li11661102351718">The level-2 partition column can be specified only when a table is created. After a table is created, the level-2 partition column cannot be modified.</li><li id="EN-US_TOPIC_0000001764675138__li8661162315177">You are not advised to specify a distribution column as a level-2 partition column.</li><li id="EN-US_TOPIC_0000001764675138__li13661132313174">The level-2 partition column determines how the table is logically split into hash partitions on DNs, which enhances the query performance for that column.</li></ul>
</div></div>
</li><li id="EN-US_TOPIC_0000001764675138__li472645316270">secondary_part_num<p id="EN-US_TOPIC_0000001764675138__p13726853192714"><a name="EN-US_TOPIC_0000001764675138__li472645316270"></a><a name="li472645316270"></a>Specifies the number of level-2 partitions in a column-store table. This parameter applies only to H-Store column-store tables. This parameter is supported only by clusters of version 8.3.0 or later.</p>
<p id="EN-US_TOPIC_0000001764675138__p272665318272">Value range: 1 to 32</p>
<p id="EN-US_TOPIC_0000001764675138__p1472765311274">Default value: <strong id="EN-US_TOPIC_0000001764675138__b164091918332021">8</strong></p>
<div class="note" id="EN-US_TOPIC_0000001764675138__note187271853142714"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><ul id="EN-US_TOPIC_0000001764675138__ul13978135331914"><li id="EN-US_TOPIC_0000001764675138__li1197825316191">This parameter can be specified only when <strong id="EN-US_TOPIC_0000001764675138__b1148337882316">secondary_part_column</strong> is specified.</li><li id="EN-US_TOPIC_0000001764675138__li997865341913">The number of level-2 partitions can be specified only when a table is created and cannot be modified after the table is created.</li><li id="EN-US_TOPIC_0000001764675138__li14978165391912">You are not advised to change the default value, which may affect the import and query performance.</li></ul>
</div></div>
</li><li id="EN-US_TOPIC_0000001764675138__li591369162">enable_hstore_opt<p id="EN-US_TOPIC_0000001764675138__p6703102814172"><a name="EN-US_TOPIC_0000001764675138__li591369162"></a><a name="li591369162"></a>If the <strong id="EN-US_TOPIC_0000001764675138__b9831149193317">enable_hstore_opt</strong> table-level parameter is enabled, the <strong id="EN-US_TOPIC_0000001764675138__b191884553333">enable_hstore</strong> table-level parameter is also enabled by default. This parameter is supported only in cluster 8.3.0 and later versions. This parameter supports V2 .</p>
<p id="EN-US_TOPIC_0000001764675138__p1013194991820">Default value: <strong id="EN-US_TOPIC_0000001764675138__b1350226645">false</strong></p>
</li><li id="EN-US_TOPIC_0000001764675138__li13145171011712">bitmap_columns<p id="EN-US_TOPIC_0000001764675138__p8440145825319"><a name="EN-US_TOPIC_0000001764675138__li13145171011712"></a><a name="li13145171011712"></a><strong id="EN-US_TOPIC_0000001764675138__b19721274367">bitmap index</strong> is only applicable to the new H-Store (<strong id="EN-US_TOPIC_0000001764675138__b163597174366">hstore_opt</strong> table). To generate the <strong id="EN-US_TOPIC_0000001764675138__b16720132773617">bitmap index</strong> mapping, you need to enable the <strong id="EN-US_TOPIC_0000001764675138__b37562554375">enable_hstore_opt</strong> table-level parameter and set <strong id="EN-US_TOPIC_0000001764675138__b184516914383">bitmap_columns</strong> to <strong id="EN-US_TOPIC_0000001764675138__b075716205389">Specified Columns</strong>. This parameter is supported only by clusters of version 8.3.0 or later.</p>
</li><li id="EN-US_TOPIC_0000001764675138__li45915863220">enable_turbo_store<p id="EN-US_TOPIC_0000001764675138__p105905853214"><a name="EN-US_TOPIC_0000001764675138__li45915863220"></a><a name="li45915863220"></a>Determines whether to create a turbo table (column-store tables). The parameter is only valid for column-store tables.</p>
<p id="EN-US_TOPIC_0000001764675138__p359558143213">Default value: <strong id="EN-US_TOPIC_0000001764675138__b402363756">off</strong></p>
<div class="note" id="EN-US_TOPIC_0000001764675138__note125915883217"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="EN-US_TOPIC_0000001764675138__p103721118131017">Turbo tables enhance the storage efficiency of numeric and varchar data types using the integers, leading to accelerated processing speeds for these types.</p>
<ul id="EN-US_TOPIC_0000001764675138__ul1364283771614"><li id="EN-US_TOPIC_0000001764675138__li1764253721616">For enhanced performance, it is advised to define the numeric type with <strong id="EN-US_TOPIC_0000001764675138__b115229010515">precision</strong> and <strong id="EN-US_TOPIC_0000001764675138__b1352216012518">scale (p, s)</strong>. The storage allocation is as follows: For p ≤ 9, 4-byte integers are used for storage. For p ≤ 18, 8-byte integers are used. For p ≤ 37, 16-byte integers are used. If p &gt; 37 or remain unspecified, a variable-length format is used, which is less space-efficient and yields suboptimal performance.</li><li id="EN-US_TOPIC_0000001764675138__li1564343751614">If the maximum length (n) of the varchar type is less than or equal to 2 bytes, 2-byte integers are used for storage. If the maximum length (n) of the varchar type is less than or equal to 4 bytes, 4-byte integers are used for storage. If the maximum length (n) of the varchar type is less than or equal to 16 bytes, 16-byte integers are used for storage. For varchar type columns involved in <strong id="EN-US_TOPIC_0000001764675138__b9757185144115">GROUP BY</strong> or <strong id="EN-US_TOPIC_0000001764675138__b14758145174114">HashJoin</strong> operations, it is advisable to limit the maximum byte length n to 16 or fewer to leverage integer storage for strings, thereby enhancing performance.</li><li id="EN-US_TOPIC_0000001764675138__li199836210257">At present, the turbo table does not have support for the timing table, delta table, and lightweight update.</li></ul>
</div></div>
</li><li id="EN-US_TOPIC_0000001764675138__en-us_topic_0000001342465185_li14679114513562"><a name="EN-US_TOPIC_0000001764675138__en-us_topic_0000001342465185_li14679114513562"></a><a name="en-us_topic_0000001342465185_li14679114513562"></a><strong id="EN-US_TOPIC_0000001764675138__b6636345114119">cache_policy</strong> (This parameter is supported only in 9.0.2 and later versions where the storage and compute nodes are decoupled.)<p id="EN-US_TOPIC_0000001764675138__en-us_topic_0000001342465185_p93251316175712">Specifies the cache mode of tables or partitioned tables (disks). If one of the following values is specified in the cache policy, hot cache is used. Otherwise, cold cache is used. Hot cache occupies more space than cold cache and uses more complex replacement policies.</p>
<p id="EN-US_TOPIC_0000001764675138__en-us_topic_0000001342465185_p1421191813717">Valid value:</p>
<ul id="EN-US_TOPIC_0000001764675138__en-us_topic_0000001342465185_ul1215032715714"><li id="EN-US_TOPIC_0000001764675138__en-us_topic_0000001342465185_li1150202713714"><strong id="EN-US_TOPIC_0000001764675138__b105958180425">ALL</strong>: Hot cache is used for the entire table.</li><li id="EN-US_TOPIC_0000001764675138__en-us_topic_0000001342465185_li18591201315912"><strong id="EN-US_TOPIC_0000001764675138__b352302114425">NONE</strong>: Cold cache is used for the entire table.</li><li id="EN-US_TOPIC_0000001764675138__en-us_topic_0000001342465185_li4319227918"><strong id="EN-US_TOPIC_0000001764675138__b123716465425">HPN</strong>: The first <em id="EN-US_TOPIC_0000001764675138__i9505162494211">N</em> partitions in a partitioned table use hot cache. The rest of the partitions use cold cache.</li><li id="EN-US_TOPIC_0000001764675138__en-us_topic_0000001342465185_li287716589136"><strong id="EN-US_TOPIC_0000001764675138__b469717559426">HPL:</strong> <em id="EN-US_TOPIC_0000001764675138__i569813552426">P1, P2, ...</em>. In a partitioned table, the specified partitions use hot cache. The rest of the partitions use cold cache.</li></ul>
<p id="EN-US_TOPIC_0000001764675138__en-us_topic_0000001342465185_p822510588213">The default value is <strong id="EN-US_TOPIC_0000001764675138__b336917291113125">ALL</strong>.</p>
<div class="note" id="EN-US_TOPIC_0000001764675138__en-us_topic_0000001342465185_note14669111018244"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><ul id="EN-US_TOPIC_0000001764675138__en-us_topic_0000001342465185_ul4214241192416"><li id="EN-US_TOPIC_0000001764675138__en-us_topic_0000001342465185_li16214441192412">For foreign tables and non-partitioned tables, only the <strong id="EN-US_TOPIC_0000001764675138__b2732135111436">ALL</strong> and <strong id="EN-US_TOPIC_0000001764675138__b107321551184319">NONE</strong> cache policies are supported.</li><li id="EN-US_TOPIC_0000001764675138__en-us_topic_0000001342465185_li1917182982614">Only range-partitioned and list-partitioned internal tables support HPN and HPL cache policies.</li></ul>
</div></div>
</li></ul>
</li><li id="EN-US_TOPIC_0000001764675138__l8778c2de5deb44879d6adc63997b804b"><strong id="EN-US_TOPIC_0000001764675138__a4e0ed1cea7a94fb38f15fd9a17dde22f">ON COMMIT { PRESERVE ROWS | DELETE ROWS }</strong><p id="EN-US_TOPIC_0000001764675138__aa82d8f22c5ce4ed9b7aec0e5a647a24c"><strong id="EN-US_TOPIC_0000001764675138__b84235270622221">ON COMMIT</strong> determines what to do when you commit a temporary table creation operation. Global temporary tables support only the <strong id="EN-US_TOPIC_0000001764675138__b18331436153917">PRESERVE ROWS</strong> option.</p>
<ul id="EN-US_TOPIC_0000001764675138__uf04036b9aecb4e38a9a87afa68f8f826"><li id="EN-US_TOPIC_0000001764675138__lec0de098db28479b9d349b28aa654574"><strong id="EN-US_TOPIC_0000001764675138__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_0000001764675138__lb2a32fb7def94ffb85f1a4b4a8c7cbe5"><strong id="EN-US_TOPIC_0000001764675138__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_0000001764675138__l452d636623504de999b1861722855da0"><strong id="EN-US_TOPIC_0000001764675138__a0ddcb239173b4ef088d9bb07443df05f">COMPRESS | NOCOMPRESS</strong><p id="EN-US_TOPIC_0000001764675138__aba870fc5cf4b409a8a48c7d2976d16b9">If you specify <strong id="EN-US_TOPIC_0000001764675138__b84235270685040">COMPRESS</strong> in the <strong id="EN-US_TOPIC_0000001764675138__b842352706222332">CREATE TABLE</strong> statement, the compression feature is triggered in the case of a bulk <strong id="EN-US_TOPIC_0000001764675138__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_0000001764675138__b6462771783">NOCOMPRESS</strong> is specified, the table is not compressed.</p>
<p id="EN-US_TOPIC_0000001764675138__ab61852391992405c930b2e42ca07d02a">Default value: <strong id="EN-US_TOPIC_0000001764675138__b842352706163420">NOCOMPRESS</strong>, tuple data is not compressed before storage.</p>
</li><li id="EN-US_TOPIC_0000001764675138__l1b1100015510493f95d6ef3eb261ea6f"><strong id="EN-US_TOPIC_0000001764675138__a44ff5ec06a60485dbe758a6c55a6d94f">DISTRIBUTE BY</strong><p id="EN-US_TOPIC_0000001764675138__a19cb82952a8146468059d792e8610de8">Specifies how the table is distributed or replicated between DNs.</p>
<p id="EN-US_TOPIC_0000001764675138__aab03e894b1604b919ed18088065dbf8f">Valid value:</p>
<ul id="EN-US_TOPIC_0000001764675138__u1d259cf19d074fda9764568b2a5d839d"><li id="EN-US_TOPIC_0000001764675138__l30d142a45e884e5cab2030dbd866588d"><strong id="EN-US_TOPIC_0000001764675138__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_0000001764675138__li108823195568"><strong id="EN-US_TOPIC_0000001764675138__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_0000001764675138__l5371e22afc33433486d5e013fc7c916a"><strong id="EN-US_TOPIC_0000001764675138__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_0000001764675138__n0b3a96f26491458aa9c897d57966df8c"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><ul id="EN-US_TOPIC_0000001764675138__uf95d23edb74a44a6aa030f93ccdbeb6c"><li id="EN-US_TOPIC_0000001764675138__l0e39717ab5dd4af592c7c669ab565dac">When <strong id="EN-US_TOPIC_0000001764675138__b730893217410">DISTRIBUTE BY HASH (column_name)</strong> is specified, the primary key and its unique index must contain the <strong id="EN-US_TOPIC_0000001764675138__b123084322412">column_name</strong> column.</li><li id="EN-US_TOPIC_0000001764675138__l31a5501f79dd4645be7e6ce15068a67a">When <strong id="EN-US_TOPIC_0000001764675138__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_0000001764675138__b203101232244">column_name</strong> column.</li><li id="EN-US_TOPIC_0000001764675138__li0412013539">If <strong id="EN-US_TOPIC_0000001764675138__b8390192318714">TO GROUP</strong> is set to a replication table node group (supported in 8.1.2 or later), <strong id="EN-US_TOPIC_0000001764675138__b105251437479">DISTRIBUTE BY</strong> must be set to <strong id="EN-US_TOPIC_0000001764675138__b81275411476">REPLICATION</strong>. If <strong id="EN-US_TOPIC_0000001764675138__b10374651877">DISTRIBUTE BY</strong> is not specified, the created table is automatically set as a replication table.</li><li id="EN-US_TOPIC_0000001764675138__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_0000001764675138__p1251615105171">Default value: determined by the GUC parameter <strong id="EN-US_TOPIC_0000001764675138__b011716451285">default_distribution_mode</strong><ul id="EN-US_TOPIC_0000001764675138__ul878364963015"><li id="EN-US_TOPIC_0000001764675138__li14783249163014">When <strong id="EN-US_TOPIC_0000001764675138__b481114201399">default_distribution_mode</strong> is set to <strong id="EN-US_TOPIC_0000001764675138__b161741329198">roundrobin</strong>, the default value of <strong id="EN-US_TOPIC_0000001764675138__b1133003416912">DISTRIBUTE BY</strong> is selected according to the following rules:<ol id="EN-US_TOPIC_0000001764675138__ol137381934837"><li id="EN-US_TOPIC_0000001764675138__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_0000001764675138__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_0000001764675138__li1645915396371">When <strong id="EN-US_TOPIC_0000001764675138__b46060081120">default_distribution_mode</strong> is set to <strong id="EN-US_TOPIC_0000001764675138__b56071109117">hash</strong>, the default value of <strong id="EN-US_TOPIC_0000001764675138__b560719013112">DISTRIBUTE BY</strong> is selected according to the following rules:<ol id="EN-US_TOPIC_0000001764675138__ol115828818381"><li id="EN-US_TOPIC_0000001764675138__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_0000001764675138__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_0000001764675138__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_0000001764675138__p613875615407">The following data types can be used as distribution columns:<ul id="EN-US_TOPIC_0000001764675138__ul8929105634111"><li id="EN-US_TOPIC_0000001764675138__li18929256194113">Integer types: <strong id="EN-US_TOPIC_0000001764675138__b10277105577">TINYINT</strong>, <strong id="EN-US_TOPIC_0000001764675138__b15277180185710">SMALLINT</strong>, <strong id="EN-US_TOPIC_0000001764675138__b122776020577">INT</strong>, <strong id="EN-US_TOPIC_0000001764675138__b1027811035720">BIGINT</strong>, and <strong id="EN-US_TOPIC_0000001764675138__b6278508578">NUMERIC/DECIMAL</strong></li><li id="EN-US_TOPIC_0000001764675138__li148954319420">Character types: <strong id="EN-US_TOPIC_0000001764675138__b139251435713">CHAR</strong>, <strong id="EN-US_TOPIC_0000001764675138__b12399101418571">BPCHAR</strong>, <strong id="EN-US_TOPIC_0000001764675138__b13399514135715">VARCHAR</strong>, <strong id="EN-US_TOPIC_0000001764675138__b640018143576">VARCHAR2</strong>, <strong id="EN-US_TOPIC_0000001764675138__b540061425713">NVARCHAR2</strong>, and <strong id="EN-US_TOPIC_0000001764675138__b17401141465716">TEXT</strong></li><li id="EN-US_TOPIC_0000001764675138__li14231162624317">Date/time types: <strong id="EN-US_TOPIC_0000001764675138__b180321819578">DATE</strong>, <strong id="EN-US_TOPIC_0000001764675138__b1581041810574">TIME</strong>, <strong id="EN-US_TOPIC_0000001764675138__b19810718155717">TIMETZ</strong>, <strong id="EN-US_TOPIC_0000001764675138__b8811121825714">TIMESTAMP</strong>, <strong id="EN-US_TOPIC_0000001764675138__b15811818165720">TIMESTAMPTZ</strong>, <strong id="EN-US_TOPIC_0000001764675138__b28111189574">INTERVAL</strong>, and <strong id="EN-US_TOPIC_0000001764675138__b148121018105711">SMALLDATETIME</strong></li></ul>
</div>
<div class="note" id="EN-US_TOPIC_0000001764675138__note11344125310577"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="EN-US_TOPIC_0000001764675138__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_0000001764675138__ul165341241165920"><li id="EN-US_TOPIC_0000001764675138__li95391941195912">Selecting an Appropriate Distribution Column<div class="p" id="EN-US_TOPIC_0000001764675138__p355034125910"><a name="EN-US_TOPIC_0000001764675138__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_0000001764675138__ol196761081903"><li id="EN-US_TOPIC_0000001764675138__li86761881012">Determine whether data is skewed.<p class="litext" id="EN-US_TOPIC_0000001764675138__p1523150301"><a name="EN-US_TOPIC_0000001764675138__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_0000001764675138__i133101074917">tablename</em> with the actual name of the table to be analyzed.</p>
<pre class="screen" id="EN-US_TOPIC_0000001764675138__screen027304016"><span id="EN-US_TOPIC_0000001764675138__text338107017"></span><strong id="EN-US_TOPIC_0000001764675138__b34220020016">SELECT a.count,b.node_name FROM (SELECT count(*) AS count,xc_node_id FROM</strong> <em id="EN-US_TOPIC_0000001764675138__i14471501011">tablename</em> <strong id="EN-US_TOPIC_0000001764675138__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_0000001764675138__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_0000001764675138__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_0000001764675138__p662318401315"><a name="EN-US_TOPIC_0000001764675138__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_0000001764675138__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_0000001764675138__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_0000001764675138__b15229102411414">REPLICATION</strong> or <strong id="EN-US_TOPIC_0000001764675138__b197737291445">ROUNDROBIN</strong> data distribution mode. The <strong id="EN-US_TOPIC_0000001764675138__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_0000001764675138__b3691713455">ROUNDROBIN</strong> data distribution mode is recommended. The <strong id="EN-US_TOPIC_0000001764675138__b974110314510">ROUNDROBIN</strong> data distribution mode is supported in 8.1.2 or later.</li></ol>
</div>
</li><li id="EN-US_TOPIC_0000001764675138__li202881859343">Selecting appropriate partition keys<p id="EN-US_TOPIC_0000001764675138__p1731014598411"><a name="EN-US_TOPIC_0000001764675138__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_0000001764675138__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_0000001764675138__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_0000001764675138__l952d2eb00a7a47bbaa7a6eab40966b69"><strong id="EN-US_TOPIC_0000001764675138__ae3a58cce858a4746a33e116011f28202">TO { GROUP groupname | NODE ( nodename [, ... ] ) }</strong><p id="EN-US_TOPIC_0000001764675138__a337dcd05ab1646748b2fc1e83c683295"><strong id="EN-US_TOPIC_0000001764675138__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_0000001764675138__b842352706152947">TO NODE</strong> is used for internal scale-out tools.</p>
<p id="EN-US_TOPIC_0000001764675138__p62633616499">In logical cluster mode, if <strong id="EN-US_TOPIC_0000001764675138__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_0000001764675138__b622612279240">OID</strong> in <strong id="EN-US_TOPIC_0000001764675138__b72769533242">pgxc_group</strong>.</p>
<p id="EN-US_TOPIC_0000001764675138__p14384553125810">If the node group specified by <strong id="EN-US_TOPIC_0000001764675138__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>
<p id="EN-US_TOPIC_0000001764675138__p26696131509">The Storage-compute decoupling 3.0 supports read-only logical clusters. If a user is not bound to any read-only logical clusters but sets <strong id="EN-US_TOPIC_0000001764675138__b18502158144312">TO GROUP</strong> to a logical cluster in a table creation statement, an error will be reported during table creation. If a user bound to a read-only logical cluster creates a table, the table will be created in the logical cluster specified by the GUC parameter <strong id="EN-US_TOPIC_0000001764675138__b125031858134313">default_storage_nodegroup</strong>. If <strong id="EN-US_TOPIC_0000001764675138__b359313295446">default_storage_nodegroup</strong> is set to <strong id="EN-US_TOPIC_0000001764675138__b165931029124414">installation</strong>, tables will be created in the first logical cluster.</p>
</li><li id="EN-US_TOPIC_0000001764675138__li568919439420"><strong id="EN-US_TOPIC_0000001764675138__b1661611920208">COMMENT [=] 'text'</strong><p id="EN-US_TOPIC_0000001764675138__p18695881579">The <strong id="EN-US_TOPIC_0000001764675138__b980816463277">COMMENT</strong> clause can specify table comments during table creation.</p>
</li><li id="EN-US_TOPIC_0000001764675138__l46786c0bcc524132bca8ab0b74952295"><strong id="EN-US_TOPIC_0000001764675138__a2081b217eae24189b7d455b5dc28db22">CONSTRAINT constraint_name</strong><p id="EN-US_TOPIC_0000001764675138__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_0000001764675138__a9431027fb104402da3f0f1ce9b3fbd06">There are two ways to define constraints:</p>
<ul id="EN-US_TOPIC_0000001764675138__u6c8f9d65434b4228813d5f953d724bf7"><li id="EN-US_TOPIC_0000001764675138__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_0000001764675138__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_0000001764675138__l30d2b1740e0148bfb5f07e997f46ef1c"><strong id="EN-US_TOPIC_0000001764675138__af9431c6ac92a4982a9fa901e53f6421b">NOT NULL</strong><p id="EN-US_TOPIC_0000001764675138__aa3bb437f01a843d7ad643e881e8554db">Indicates that the column is not allowed to contain <strong id="EN-US_TOPIC_0000001764675138__b87912263144857">NULL</strong> values.</p>
</li><li id="EN-US_TOPIC_0000001764675138__l88137e4d693a48a1a9c6289b75da0f30"><strong id="EN-US_TOPIC_0000001764675138__a0351f2a212154d13a48788f2cc7b8b3d">NULL</strong><p id="EN-US_TOPIC_0000001764675138__ae2ce887f32fc409996a3c45909a044ad">The column is allowed to contain <strong id="EN-US_TOPIC_0000001764675138__b842352706104637">NULL</strong> values. This is the default setting.</p>
<p id="EN-US_TOPIC_0000001764675138__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_0000001764675138__l62ab5db2e605425ba1475dd7010404e4"><strong id="EN-US_TOPIC_0000001764675138__a445d552fe9ae4d1ea848bf15afd0ac5e">CHECK ( expression )</strong><p id="EN-US_TOPIC_0000001764675138__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_0000001764675138__b84235270616515">TRUE</strong> or <strong id="EN-US_TOPIC_0000001764675138__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_0000001764675138__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_0000001764675138__note354734852610"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="EN-US_TOPIC_0000001764675138__p755211489268"><strong id="EN-US_TOPIC_0000001764675138__b14435145412214">&lt;&gt;NULL</strong> and <strong id="EN-US_TOPIC_0000001764675138__b1243720541026">!=NULL</strong> are invalid in an expression. Change them to <strong id="EN-US_TOPIC_0000001764675138__b144741956221">IS NOT NULL</strong>.</p>
</div></div>
</li><li id="EN-US_TOPIC_0000001764675138__l723523fcfe234f5d9744697a100a2d5b"><strong id="EN-US_TOPIC_0000001764675138__ae12044be71b94ca7bff594caad8bcc1b">DEFAULT default_expr</strong><p id="EN-US_TOPIC_0000001764675138__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_0000001764675138__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_0000001764675138__b842352706104725">NULL</strong>.</p>
</li><li id="EN-US_TOPIC_0000001764675138__li11429032440"><strong id="EN-US_TOPIC_0000001764675138__b1058672261">ON UPDATE on_update_expr</strong><p id="EN-US_TOPIC_0000001764675138__p13682811588">The <strong id="EN-US_TOPIC_0000001764675138__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_0000001764675138__b113713579237">ON UPDATE</strong> clause specifies a timestamp function is timestamp or timestamptz.</p>
<p id="EN-US_TOPIC_0000001764675138__p1725411481140">When an SQL statement containing the <strong id="EN-US_TOPIC_0000001764675138__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_0000001764675138__note19776409141"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="EN-US_TOPIC_0000001764675138__p109771940101413">The <strong id="EN-US_TOPIC_0000001764675138__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_0000001764675138__li9964195916187"><strong id="EN-US_TOPIC_0000001764675138__b17673421111913">COMMENT</strong><strong id="EN-US_TOPIC_0000001764675138__b8385201192010"> 'text'</strong><p id="EN-US_TOPIC_0000001764675138__p163036125201">The <strong id="EN-US_TOPIC_0000001764675138__b1831163372820">COMMENT</strong> clause can specify a comment for a column.</p>
</li><li id="EN-US_TOPIC_0000001764675138__l3947318658d747c0b403f7087fd9a662"><strong id="EN-US_TOPIC_0000001764675138__a403ac85ea7d44ff095eb59aaf8819053">UNIQUE [ NULLS [ NOT ] DISTINCT | NULLS IGNORE ] index_parameters</strong><p id="EN-US_TOPIC_0000001764675138__a470845db7cd14428bef79486a01d2295"><strong id="EN-US_TOPIC_0000001764675138__a8b6f1b6dbf8d4418a46a9bd65997d3ac">UNIQUE [ NULLS [ NOT ] DISTINCT | NULLS IGNORE ] ( column_name [, ... ] ) index_parameters</strong></p>
<p id="EN-US_TOPIC_0000001764675138__aecada5190e5f468eaff4d903bea0f476">Specifies that a group of one or more columns of a table can contain only unique values.</p>
<p id="EN-US_TOPIC_0000001764675138__p393220118438">The <strong id="EN-US_TOPIC_0000001764675138__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_0000001764675138__p1636261210525">Default value: This parameter is left empty by default. NULL values can be inserted repeatedly.</p>
<p id="EN-US_TOPIC_0000001764675138__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_0000001764675138__ul970814364497"><li id="EN-US_TOPIC_0000001764675138__li670811365497">NULLS DISTINCT: NULL values are unequal and can be inserted repeatedly.</li><li id="EN-US_TOPIC_0000001764675138__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_0000001764675138__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_0000001764675138__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_0000001764675138__table1449412571407" frame="border" border="1" rules="all"><caption><b>Table 3 </b>Processing of NULL values in index columns in unique indexes</caption><thead align="left"><tr id="EN-US_TOPIC_0000001764675138__row104951657207"><th align="left" class="cellrowborder" valign="top" width="33.25%" id="mcps1.3.9.2.24.9.2.4.1.1"><p id="EN-US_TOPIC_0000001764675138__p149595719017">Constraint</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="24.529999999999998%" id="mcps1.3.9.2.24.9.2.4.1.2"><p id="EN-US_TOPIC_0000001764675138__p2495057208">All Index Columns Are NULL</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="42.22%" id="mcps1.3.9.2.24.9.2.4.1.3"><p id="EN-US_TOPIC_0000001764675138__p1649535719015">Some Index Columns Are NULL.</p>
</th>
</tr>
</thead>
<tbody><tr id="EN-US_TOPIC_0000001764675138__row94953571505"><td class="cellrowborder" valign="top" width="33.25%" headers="mcps1.3.9.2.24.9.2.4.1.1 "><p id="EN-US_TOPIC_0000001764675138__p174951057901">NULLS DISTINCT</p>
</td>
<td class="cellrowborder" valign="top" width="24.529999999999998%" headers="mcps1.3.9.2.24.9.2.4.1.2 "><p id="EN-US_TOPIC_0000001764675138__p549825711016">Can be inserted repeatedly.</p>
</td>
<td class="cellrowborder" valign="top" width="42.22%" headers="mcps1.3.9.2.24.9.2.4.1.3 "><p id="EN-US_TOPIC_0000001764675138__p149895712010">Can be inserted repeatedly.</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001764675138__row6498165715017"><td class="cellrowborder" valign="top" width="33.25%" headers="mcps1.3.9.2.24.9.2.4.1.1 "><p id="EN-US_TOPIC_0000001764675138__p154981570020">NULLS NOT DISTINCT</p>
</td>
<td class="cellrowborder" valign="top" width="24.529999999999998%" headers="mcps1.3.9.2.24.9.2.4.1.2 "><p id="EN-US_TOPIC_0000001764675138__p64981657107">Cannot be inserted repeatedly.</p>
</td>
<td class="cellrowborder" valign="top" width="42.22%" headers="mcps1.3.9.2.24.9.2.4.1.3 "><p id="EN-US_TOPIC_0000001764675138__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_0000001764675138__row9498557705"><td class="cellrowborder" valign="top" width="33.25%" headers="mcps1.3.9.2.24.9.2.4.1.1 "><p id="EN-US_TOPIC_0000001764675138__p2049811579012">NULLS IGNORE</p>
</td>
<td class="cellrowborder" valign="top" width="24.529999999999998%" headers="mcps1.3.9.2.24.9.2.4.1.2 "><p id="EN-US_TOPIC_0000001764675138__p74983571008">Can be inserted repeatedly.</p>
</td>
<td class="cellrowborder" valign="top" width="42.22%" headers="mcps1.3.9.2.24.9.2.4.1.3 "><p id="EN-US_TOPIC_0000001764675138__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_0000001764675138__n5c787c39852f41ee98e8f9aec419aeb3"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="EN-US_TOPIC_0000001764675138__a647bf5485229466f9085fe5db6f6ed2c">If <strong id="EN-US_TOPIC_0000001764675138__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_0000001764675138__l61a58f471c2a41178cea62e34b75609e"><strong id="EN-US_TOPIC_0000001764675138__aead44124bc5c4467b08efadb591637ac">PRIMARY KEY index_parameters</strong><p id="EN-US_TOPIC_0000001764675138__a139d3146dc50420b85805015313d97d0"><strong id="EN-US_TOPIC_0000001764675138__ad33d94e660bd41ce88f2504f99a0ef7d">PRIMARY KEY ( column_name [, ... ] ) index_parameters</strong></p>
<p id="EN-US_TOPIC_0000001764675138__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_0000001764675138__af35e3b0d1eb8457b9fde40db514c6708">Only one primary key can be specified for a table.</p>
<div class="note" id="EN-US_TOPIC_0000001764675138__n18e8fd59d5ef457cbeec615f6f07d9fe"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="EN-US_TOPIC_0000001764675138__a612f61a539c94ce4841136a1e1d194a6">If <strong id="EN-US_TOPIC_0000001764675138__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_0000001764675138__li618611302148"><strong id="EN-US_TOPIC_0000001764675138__b19001169711">REFERENCES reftable [ ( refcolumn ) ]</strong><p id="EN-US_TOPIC_0000001764675138__p1442617610197">The foreign key constraint requires that the group consisting of one or more columns in the new table should contain and match only the referenced column values in the referenced table. The referenced column should be the only column or primary key in the referenced table.</p>
<div class="note" id="EN-US_TOPIC_0000001764675138__note1855911138576"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="EN-US_TOPIC_0000001764675138__p055951355714">GaussDB(DWS) does not check foreign key constraints. When using foreign key constraints, you need to use the <strong id="EN-US_TOPIC_0000001764675138__b850813715619">check_foreign_key_constraint</strong> function to check whether the data in the foreign key table meets the foreign key constraints.</p>
</div></div>
</li><li id="EN-US_TOPIC_0000001764675138__ld504902f528d4b15b74d4e19a9e80627"><strong id="EN-US_TOPIC_0000001764675138__a955d98a5445a42f1a9fa5d6de093af02">DEFERRABLE | NOT DEFERRABLE</strong><p id="EN-US_TOPIC_0000001764675138__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_0000001764675138__b60118629161614">SET CONSTRAINTS</strong> command. <strong id="EN-US_TOPIC_0000001764675138__b37770752161614">NOT DEFERRABLE</strong> is the default value. Currently, only <strong id="EN-US_TOPIC_0000001764675138__b842352706165150">UNIQUE</strong> and <strong id="EN-US_TOPIC_0000001764675138__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_0000001764675138__li490420236428"><strong id="EN-US_TOPIC_0000001764675138__b194681910164">PARTIAL CLUSTER KEY</strong><p id="EN-US_TOPIC_0000001764675138__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_0000001764675138__le49188cd0ea9445bb11c4ffba407db2e"><strong id="EN-US_TOPIC_0000001764675138__abbad7cac0fba4d5184597e50e26b2d40">INITIALLY IMMEDIATE | INITIALLY DEFERRED</strong><p id="EN-US_TOPIC_0000001764675138__a23370860b6a340e982a08d6ede865ede">If a constraint is deferrable, this clause specifies the default time to check the constraint.</p>
<ul id="EN-US_TOPIC_0000001764675138__u882f54932fb14e639393bdb51c8f54de"><li id="EN-US_TOPIC_0000001764675138__lc2d668e5ba944b388e26f8ad78eb23d1">If the constraint is <strong id="EN-US_TOPIC_0000001764675138__b44131592161921">INITIALLY IMMEDIATE</strong> (default value), it is checked after each statement.</li><li id="EN-US_TOPIC_0000001764675138__ld299e8bbef5a4cf18d9fe7a0be476c4b">If the constraint is <strong id="EN-US_TOPIC_0000001764675138__b17889208161921">INITIALLY DEFERRED</strong>, it is checked only at the end of the transaction.</li></ul>
<p id="EN-US_TOPIC_0000001764675138__ae2d1db393a0a4242b3665193edc024ab">The constraint check time can be altered using the <strong id="EN-US_TOPIC_0000001764675138__b39739724161921">SET CONSTRAINTS</strong> command.</p>
</li></ul>
</div>
<div class="section" id="EN-US_TOPIC_0000001764675138__section75712037183317"><h4 class="sectiontitle">Examples</h4><p id="EN-US_TOPIC_0000001764675138__p12861459195116">Create a V3 table with storage and compute decoupled (supported only in the storage-compute decoupling 3.0 version).</p>
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001764675138__screen1052616415384"><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="k">public</span><span class="p">.</span><span class="n">t1</span><span class="w"> </span>
<span class="p">(</span><span class="w"> </span>
<span class="n">id</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="k">data</span><span class="w"> </span><span class="nb">integer</span><span class="p">,</span><span class="w"> </span>
<span class="n">age</span><span class="w"> </span><span class="nb">integer</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="n">ORIENTATION</span><span class="w"> </span><span class="o">=</span><span class="k">COLUMN</span><span class="p">,</span><span class="w"> </span><span class="n">COLVERSION</span><span class="w"> </span><span class="o">=</span><span class="mi">3</span><span class="p">.</span><span class="mi">0</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="n">ROUNDROBIN</span><span class="p">;</span>
</pre></div></td></tr></table></div>
</div>
<p id="EN-US_TOPIC_0000001764675138__en-us_topic_0000001342465185_p172111449141417">Specify the cache policy when creating a table (supported only in clusters of the storage-compute decoupling 3.0 version).</p>
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001764675138__en-us_topic_0000001342465185_screen211311127157"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal"> 1</span>
<span class="normal"> 2</span>
<span class="normal"> 3</span>
<span class="normal"> 4</span>
<span class="normal"> 5</span>
<span class="normal"> 6</span>
<span class="normal"> 7</span>
<span class="normal"> 8</span>
<span class="normal"> 9</span>
<span class="normal">10</span>
<span class="normal">11</span>
<span class="normal">12</span>
<span class="normal">13</span>
<span class="normal">14</span>
<span class="normal">15</span>
<span class="normal">16</span>
<span class="normal">17</span></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">Sports</span>
<span class="p">(</span>
<span class="w"> </span><span class="n">N_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="p">,</span><span class="w"> </span><span class="n">N_NAME</span><span class="w"> </span><span class="nb">CHAR</span><span class="p">(</span><span class="mi">25</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">N_REGIONKEY</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="p">,</span><span class="w"> </span><span class="n">N_COMMENT</span><span class="w"> </span><span class="nb">VARCHAR</span><span class="p">(</span><span class="mi">152</span><span class="p">)</span>
<span class="p">)</span><span class="w"> </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">colversion</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">3</span><span class="p">.</span><span class="mi">0</span><span class="p">,</span><span class="w"> </span><span class="n">cache_policy</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'HPL: Balls, Basketball'</span><span class="p">)</span>
<span class="n">tablespace</span><span class="w"> </span><span class="n">cu_obs_tbs</span>
<span class="n">DISTRIBUTE</span><span class="w"> </span><span class="k">BY</span><span class="w"> </span><span class="n">ROUNDROBIN</span>
<span class="n">partition</span><span class="w"> </span><span class="k">by</span><span class="w"> </span><span class="n">list</span><span class="p">(</span><span class="n">N_NAME</span><span class="p">)</span>
<span class="p">(</span>
<span class="w"> </span><span class="n">partition</span><span class="w"> </span><span class="n">Balls</span><span class="w"> </span><span class="k">values</span><span class="w"> </span><span class="p">(</span><span class="s1">'Basketball'</span><span class="p">,</span><span class="w"> </span><span class="s1">'football'</span><span class="p">,</span><span class="w"> </span><span class="s1">'badminton'</span><span class="p">),</span>
<span class="w"> </span><span class="n">partition</span><span class="w"> </span><span class="n">Athletics</span><span class="w"> </span><span class="k">values</span><span class="w"> </span><span class="p">(</span><span class="s1">'High jump'</span><span class="p">,</span><span class="w"> </span><span class="s1">'long jump'</span><span class="p">,</span><span class="w"> </span><span class="s1">'javelin'</span><span class="p">),</span>
<span class="w"> </span><span class="n">partition</span><span class="w"> </span><span class="n">Water_Sports</span><span class="w"> </span><span class="k">values</span><span class="w"> </span><span class="p">(</span><span class="s1">'Surfing'</span><span class="p">,</span><span class="w"> </span><span class="s1">'diving'</span><span class="p">,</span><span class="w"> </span><span class="s1">'swimming'</span><span class="p">),</span>
<span class="w"> </span><span class="n">partition</span><span class="w"> </span><span class="n">Shooting</span><span class="w"> </span><span class="k">values</span><span class="w"> </span><span class="p">(</span><span class="s1">'air guns'</span><span class="p">,</span><span class="w"> </span><span class="s1">'Rifles'</span><span class="p">,</span><span class="w"> </span><span class="s1">'archery'</span><span class="p">),</span>
<span class="w"> </span><span class="n">partition</span><span class="w"> </span><span class="n">rest</span><span class="w"> </span><span class="k">values</span><span class="w"> </span><span class="p">(</span><span class="k">DEFAULT</span><span class="p">)</span>
<span class="p">);</span>
</pre></div></td></tr></table></div>
</div>
<p id="EN-US_TOPIC_0000001764675138__p13831105315549">Define a unique column constraint for the table:</p>
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001764675138__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_0000001764675138__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_0000001764675138__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_0000001764675138__p883295395410">Define the <strong id="EN-US_TOPIC_0000001764675138__b1332656867103716">CHECK</strong> column constraint:</p>
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001764675138__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_0000001764675138__p12833175318546">Define the <strong id="EN-US_TOPIC_0000001764675138__b1160993667103716">CHECK</strong> table constraint:</p>
<pre class="screen" id="EN-US_TOPIC_0000001764675138__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_0000001764675138__p16833125314542">Create a column-store table and specify the storage format and compression mode:</p>
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001764675138__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_0000001764675138__p78337531549">Use <strong id="EN-US_TOPIC_0000001764675138__b1438027898103716">DEFAULT</strong> to declare a default value for column <strong id="EN-US_TOPIC_0000001764675138__b114052980103716">W_STATE</strong>:</p>
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001764675138__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_0000001764675138__p48347532545">Create the <strong id="EN-US_TOPIC_0000001764675138__b1410283156103716">CUSTOMER_bk</strong> table in LIKE mode:</p>
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001764675138__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_0000001764675138__sbd5006c0aa874ae59e4fa1608060e587"><h4 class="sectiontitle">Helpful Links</h4><p id="EN-US_TOPIC_0000001764675138__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>