forked from docs/doc-exports
Reviewed-by: Pruthi, Vineet <vineet.pruthi@t-systems.com> Co-authored-by: Lu, Huayi <luhuayi@huawei.com> Co-committed-by: Lu, Huayi <luhuayi@huawei.com>
268 lines
45 KiB
HTML
268 lines
45 KiB
HTML
<a name="EN-US_TOPIC_0000001510522721"></a><a name="EN-US_TOPIC_0000001510522721"></a>
|
|
|
|
<h1 class="topictitle1">Creating and Managing Tables</h1>
|
|
<div id="body8662426"><div class="section" id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_section1571232211220"><h4 class="sectiontitle">Creating a Table</h4><p id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_p364142411413">You can run the <strong id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_b149215913264">CREATE TABLE</strong> command to create a table. When creating a table, you can define the following information:</p>
|
|
<ul id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_ul18968148112618"><li id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_li10222195812398">Columns and data type of the table.</li><li id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_li1296808152612">Table or column constraints that restrict a column or the data contained in a table. For details, see <a href="#EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_section88441546443">Definition of Table Constraints</a>.</li><li id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_li2096918818269">Distribution policy of a table, which determines how the GaussDB (DWS) database divides data between segments. For details, see <a href="#EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_section14268111013444">Definition of Table Distribution</a>.</li><li id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_li149696852614">Table storage format. For details, see <a href="dws_04_0026.html#EN-US_TOPIC_0000001460562840">Selecting a Table Storage Mode</a>.</li><li id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_li12969198132611">Partition table information. For details, see <a href="dws_04_0037.html#EN-US_TOPIC_0000001510402657">Defining Table Partitions</a>.</li></ul>
|
|
</div>
|
|
<p id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_p15194306404">Example: Use <strong id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_b9934204264511">CREATE TABLE </strong>to create a table <strong id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_b427612518454">web_returns_p1</strong>, use <strong id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_b12190131184612">wr_item_sk</strong> as the distribution key, and sets the range distribution function through <strong id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_b7343151514617">wr_returned_date_sk</strong>.</p>
|
|
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_screen13819519154013"><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></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">web_returns_p1</span>
|
|
<span class="p">(</span>
|
|
<span class="w"> </span><span class="n">wr_returned_date_sk</span><span class="w"> </span><span class="nb">integer</span><span class="p">,</span>
|
|
<span class="w"> </span><span class="n">wr_returned_time_sk</span><span class="w"> </span><span class="nb">integer</span><span class="p">,</span>
|
|
<span class="w"> </span><span class="n">wr_item_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">wr_refunded_customer_sk</span><span class="w"> </span><span class="nb">integer</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="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">wr_item_sk</span><span class="p">)</span>
|
|
<span class="n">PARTITION</span><span class="w"> </span><span class="k">BY</span><span class="w"> </span><span class="n">RANGE</span><span class="p">(</span><span class="n">wr_returned_date_sk</span><span class="p">)</span>
|
|
<span class="p">(</span>
|
|
<span class="w"> </span><span class="n">PARTITION</span><span class="w"> </span><span class="n">p2019</span><span class="w"> </span><span class="k">START</span><span class="p">(</span><span class="mi">20191231</span><span class="p">)</span><span class="w"> </span><span class="k">END</span><span class="p">(</span><span class="mi">20221231</span><span class="p">)</span><span class="w"> </span><span class="k">EVERY</span><span class="p">(</span><span class="mi">10000</span><span class="p">),</span>
|
|
<span class="w"> </span><span class="n">PARTITION</span><span class="w"> </span><span class="n">p0</span><span class="w"> </span><span class="k">END</span><span class="p">(</span><span class="k">maxvalue</span><span class="p">)</span>
|
|
<span class="p">);</span>
|
|
</pre></div></td></tr></table></div>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_section88441546443"><a name="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_section88441546443"></a><a name="en-us_topic_0000001233681653_section88441546443"></a><h4 class="sectiontitle">Definition of Table Constraints</h4><p id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_p685018472312">You can define constraints on columns and tables to restrict data in a table. However, there are the following restrictions:</p>
|
|
<ul id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_ul122071812193617"><li id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_li16207131212364">The primary key constraint and unique constraint in the table must contain a distribution column.</li><li id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_li1620714120367">Column-store tables support the <strong id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_b116869805541914">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_0000001510522721__en-us_topic_0000001233681653_li520712121368">Only the <strong id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_b171466321232">NULL</strong>, <strong id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_b13146432332">NOT NULL</strong>, and <strong id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_b14147732434">DEFAULT </strong>constant values can be used as column-store table column constraints.</li></ul>
|
|
|
|
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_table04475017536" frame="border" border="1" rules="all"><caption><b>Table 1 </b>Table constraints</caption><thead align="left"><tr id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_row134488019533"><th align="left" class="cellrowborder" valign="top" width="15%" id="mcps1.3.4.4.2.4.1.1"><p id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_p04480045316">Constraint</p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="35%" id="mcps1.3.4.4.2.4.1.2"><p id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_p15448120195312">Description</p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="50%" id="mcps1.3.4.4.2.4.1.3"><p id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_p4448200155316">Example</p>
|
|
</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody><tr id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_row13448608534"><td class="cellrowborder" valign="top" width="15%" headers="mcps1.3.4.4.2.4.1.1 "><p id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_p1028293820534">Check constraint</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="35%" headers="mcps1.3.4.4.2.4.1.2 "><p id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_p184497045317">A CHECK constraint allows you to specify that values in a specific column must satisfy a Boolean (true) expression.</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.4.4.2.4.1.3 "><p id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_p2449190175311">Create the <strong id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_b236413171095">products</strong> table. The <strong id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_b693852819916">price</strong> column must be positive.</p>
|
|
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_screen834717075418"><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="k">CREATE</span><span class="w"> </span><span class="k">TABLE</span><span class="w"> </span><span class="n">products</span>
|
|
<span class="p">(</span>
|
|
<span class="w"> </span><span class="n">product_no</span><span class="w"> </span><span class="nb">integer</span><span class="p">,</span><span class="w"> </span>
|
|
<span class="w"> </span><span class="n">name</span><span class="w"> </span><span class="nb">text</span><span class="p">,</span><span class="w"> </span>
|
|
<span class="w"> </span><span class="n">price</span><span class="w"> </span><span class="nb">numeric</span><span class="w"> </span><span class="k">CHECK</span><span class="w"> </span><span class="p">(</span><span class="n">price</span><span class="w"> </span><span class="o">></span><span class="w"> </span><span class="mi">0</span><span class="p">)</span>
|
|
<span class="p">);</span>
|
|
</pre></div></td></tr></table></div>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
<tr id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_row544920085317"><td class="cellrowborder" valign="top" width="15%" headers="mcps1.3.4.4.2.4.1.1 "><p id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_p134490075318">NOT NULL constraint</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="35%" headers="mcps1.3.4.4.2.4.1.2 "><p id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_p18449120155317">A NOT NULL constraint specifies that a column cannot have null values. A non-null constraint is always written as a column constraint.</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.4.4.2.4.1.3 "><p id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_p164492016532">Create the <strong id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_b1827716448914">products</strong> table. The values of <strong id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_b116533537915">product_no</strong> and <strong id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_b1518265719919">name</strong> cannot be null.</p>
|
|
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_screen1619361215"><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="k">CREATE</span><span class="w"> </span><span class="k">TABLE</span><span class="w"> </span><span class="n">products</span><span class="w"> </span>
|
|
<span class="p">(</span><span class="w"> </span>
|
|
<span class="w"> </span><span class="n">product_no</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">name</span><span class="w"> </span><span class="nb">text</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">price</span><span class="w"> </span><span class="nb">numeric</span><span class="w"> </span>
|
|
<span class="p">);</span>
|
|
</pre></div></td></tr></table></div>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
<tr id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_row84494015533"><td class="cellrowborder" valign="top" width="15%" headers="mcps1.3.4.4.2.4.1.1 "><p id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_p18704181018551">UNIQUE constraint</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="35%" headers="mcps1.3.4.4.2.4.1.2 "><p id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_p1044980165310">A UNIQUE constraint specifies that the values in a column or a group of columns are all unique. If <strong id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_b16710110964540">DISTRIBUTE BY REPLICATION</strong> is not specified, the column table that contains only unique values must contain distribution columns.</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.4.4.2.4.1.3 "><p id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_p13229155116148">Create the<strong id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_b15331111619173"> products</strong> table. The values of <strong id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_b1765192416179">product_no</strong> must be unique.</p>
|
|
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_screen18295104231217"><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="k">CREATE</span><span class="w"> </span><span class="k">TABLE</span><span class="w"> </span><span class="n">products</span><span class="w"> </span>
|
|
<span class="p">(</span>
|
|
<span class="w"> </span><span class="n">product_no</span><span class="w"> </span><span class="nb">integer</span><span class="w"> </span><span class="k">UNIQUE</span><span class="p">,</span><span class="w"> </span>
|
|
<span class="w"> </span><span class="n">name</span><span class="w"> </span><span class="nb">text</span><span class="p">,</span><span class="w"> </span>
|
|
<span class="w"> </span><span class="n">price</span><span class="w"> </span><span class="nb">numeric</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">product_no</span><span class="p">);</span>
|
|
</pre></div></td></tr></table></div>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
<tr id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_row144497019535"><td class="cellrowborder" valign="top" width="15%" headers="mcps1.3.4.4.2.4.1.1 "><p id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_p14494025318">Primary key constraint</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="35%" headers="mcps1.3.4.4.2.4.1.2 "><p id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_p1754712508123">A primary key constraint is the combination of a UNIQUE constraint and a NOT NULL constraint. If <strong id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_b642462654615">DISTRIBUTE BY REPLICATION</strong> is not specified, the column set with a primary key constraint must contain distributed columns. If a table has a primary key, the column (or group of columns) of the primary key is selected as the distribution keys of the table by default.</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.4.4.2.4.1.3 "><p id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_p6150197151515">Create the <strong id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_b1356185418176">products</strong> table. The primary key constraint is <strong id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_b11735145018175">product_no</strong>.</p>
|
|
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_screen62202059131211"><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="k">CREATE</span><span class="w"> </span><span class="k">TABLE</span><span class="w"> </span><span class="n">products</span><span class="w"> </span>
|
|
<span class="p">(</span><span class="w"> </span>
|
|
<span class="w"> </span><span class="n">product_no</span><span class="w"> </span><span class="nb">integer</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="w"> </span>
|
|
<span class="w"> </span><span class="n">name</span><span class="w"> </span><span class="nb">text</span><span class="p">,</span><span class="w"> </span>
|
|
<span class="w"> </span><span class="n">price</span><span class="w"> </span><span class="nb">numeric</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">product_no</span><span class="p">);</span>
|
|
</pre></div></td></tr></table></div>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
<tr id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_row94501304532"><td class="cellrowborder" valign="top" width="15%" headers="mcps1.3.4.4.2.4.1.1 "><p id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_p2131512145512">Partial cluster key</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="35%" headers="mcps1.3.4.4.2.4.1.2 "><p id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_p84504075310">Partial cluster key can minimize or maximize sparse indexes to quickly filter base tables. Partial cluster key can specify multiple columns, but you are advised to specify no more than two columns.</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.4.4.2.4.1.3 "><p id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_p1236191711157">Create the <strong id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_b204003912187">products</strong> table with PCK set to <strong id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_b4310154412182">product_no</strong>:</p>
|
|
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_screen14185102771515"><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></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">products</span><span class="w"> </span>
|
|
<span class="p">(</span>
|
|
<span class="w"> </span><span class="n">product_no</span><span class="w"> </span><span class="nb">integer</span><span class="p">,</span><span class="w"> </span>
|
|
<span class="w"> </span><span class="n">name</span><span class="w"> </span><span class="nb">text</span><span class="p">,</span><span class="w"> </span>
|
|
<span class="w"> </span><span class="n">price</span><span class="w"> </span><span class="nb">numeric</span><span class="p">,</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="p">(</span><span class="n">product_no</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>
|
|
</pre></div></td></tr></table></div>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_section14268111013444"><a name="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_section14268111013444"></a><a name="en-us_topic_0000001233681653_section14268111013444"></a><h4 class="sectiontitle">Definition of Table Distribution</h4><div class="p" id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_p1083615282362">GaussDB(DWS) supports the following distribution modes: replication, hash, and roundrobin.<div class="note" id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_note15265119111"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_p1226531917120">The roundrobin distribution mode is supported only by cluster version 8.1.2 or later.</p>
|
|
</div></div>
|
|
|
|
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_t96d578ad8418495b9f89d5660dfc18d8" frame="border" border="1" rules="all"><thead align="left"><tr id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_r6d47328d94bc47a19c573843c94381e0"><th align="left" class="cellrowborder" valign="top" width="15%" id="mcps1.3.5.2.2.1.5.1.1"><p id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_a5f63996a0e7f41f5b205102c837b2c46"><strong id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_b12153239163620">Policy</strong></p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="22.5%" id="mcps1.3.5.2.2.1.5.1.2"><p id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_af83b45faa3354bddbdcb2670513e5122"><strong id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_adafbbc31dcf44e9ab9fbfb759ba6217b">Description</strong></p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="22.5%" id="mcps1.3.5.2.2.1.5.1.3"><p id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_ae2ac075156d846fcbee19d34da7337dc"><strong id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_b19160044103616">Scenario</strong></p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="40%" id="mcps1.3.5.2.2.1.5.1.4"><p id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_p37135811211">Advantages/Disadvantages</p>
|
|
</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody><tr id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_row22891533205"><td class="cellrowborder" valign="top" width="15%" headers="mcps1.3.5.2.2.1.5.1.1 "><p id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_p3561914125518">Replication</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="22.5%" headers="mcps1.3.5.2.2.1.5.1.2 "><p id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_a8a88424b71cc455f8093cdd450c98563">Full data in a table is stored on each DN in the cluster.</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="22.5%" headers="mcps1.3.5.2.2.1.5.1.3 "><p id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_a5b779edb582e4be1a210ef17368754aa">Small tables and dimension tables</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="40%" headers="mcps1.3.5.2.2.1.5.1.4 "><ul id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_ul854011201422"><li id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_li195404201629">The advantage of replication is that each DN has full data of the table. During the join operation, data does not need to be redistributed, reducing network overheads and reducing plan segments (each plan segment starts a corresponding thread).</li><li id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_li85401220221">The disadvantage of replication is that each DN retains the complete data of the table, resulting in data redundancy. Generally, replication is only used for small dimension tables.</li></ul>
|
|
</td>
|
|
</tr>
|
|
<tr id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_rf0a00b3c5077429db9fa9a46e0031298"><td class="cellrowborder" valign="top" width="15%" headers="mcps1.3.5.2.2.1.5.1.1 "><p id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_ad559b18c7b8348b39f6ef201bc392045">Hash</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="22.5%" headers="mcps1.3.5.2.2.1.5.1.2 "><p id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_aa231150682484df396a1a63cb522fba1">Table data is distributed on all DNs in the cluster.</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="22.5%" headers="mcps1.3.5.2.2.1.5.1.3 "><p id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_aa876866ab9cf47bf9b4954c1ac9e7dfa">Fact tables containing a large amount of data</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="40%" headers="mcps1.3.5.2.2.1.5.1.4 "><ul id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_ul52147339519"><li id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_li221417334519">The I/O resources of each node can be used during data read/write, greatly improving the read/write speed of a table.</li><li id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_li521416331457">Generally, a large table (containing over 1 million records) is defined as a hash table.</li></ul>
|
|
</td>
|
|
</tr>
|
|
<tr id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_row10809175183514"><td class="cellrowborder" valign="top" width="15%" headers="mcps1.3.5.2.2.1.5.1.1 "><p id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_p16810185113518">Polling (Round-robin)</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="22.5%" headers="mcps1.3.5.2.2.1.5.1.2 "><p id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_p781015113512">Each row in the table is sent to each DN in turn. Data can be evenly distributed on each DN.</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="22.5%" headers="mcps1.3.5.2.2.1.5.1.3 "><p id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_p699994419594">Fact tables that contain a large amount of data and cannot find a proper distribution column in hash mode</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="40%" headers="mcps1.3.5.2.2.1.5.1.4 "><ul id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_ul18621614535"><li id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_li1628145316">Round-robin can avoid data skew, improving the space utilization of the cluster.</li><li id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_li162714221957">Round-robin does not support local DN optimization like a hash table does, and the query performance of Round-robin is usually lower than that of a hash table.</li><li id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_li10644416150">If a proper distribution column can be found for a large table, use the hash distribution mode with better performance. Otherwise, define the table as a round-robin table.</li></ul>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<p id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_p19516151223719"><strong id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_b18950355131818">Selecting a Distribution Key</strong></p>
|
|
<p id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_p85448281156">If the hash distribution mode is used, a distribution key must be specified for the user table. When a record is inserted, the system hashes it based on the distribution key and then stores it on the corresponding DN.</p>
|
|
<p id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_a8bc4b1964cee4988bba61310304ea8b8">Select a hash distribution key based on the following principles:</p>
|
|
<ol id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_ol29343014911"><li id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_li993416017495"><strong id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_a2e01a4d39fa04d51814bf0093d04a484">The values of the distribution key should be discrete so that data can be evenly distributed on each DN.</strong> You can select the primary key of the table as the distribution key. For example, for a person information table, choose the ID number column as the distribution key.</li><li id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_li993480194918"><strong id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_a529edd2e23f940089b97f079e83d44f2">Do not select the column that has a constant filter.</strong> For example, if a constant constraint (for example, zqdh= '000001') exists on the <strong id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_b202559171141914">zqdh</strong> column in some queries on the <strong id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_b66813244441914">dwcjk</strong> table, you are not advised to use <strong id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_b102732138041914">zqdh</strong> as the distribution key.</li><li id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_li4935110124917"><strong id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_a5d53bae347be4959a7d42f087d6ab01a">With the above principles met, you can select join conditions as distribution keys</strong>, so that join tasks can be pushed down to DNs for execution, reducing the amount of data transferred between the DNs.<p id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_a4af0ed216612409ea73522d1b1f5ae64">For a hash table, an inappropriate distribution key may cause data skew or poor I/O performance on certain DNs. Therefore, you need to check the table to ensure that data is evenly distributed on each DN. You can run the following SQL statements to check for data skew:</p>
|
|
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_s9b81a8050014459d962cffd10a0611b5"><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></pre></div></td><td class="code"><div><pre><span></span><span class="k">select</span><span class="w"> </span>
|
|
<span class="n">xc_node_id</span><span class="p">,</span><span class="w"> </span><span class="k">count</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span><span class="w"> </span>
|
|
<span class="k">from</span><span class="w"> </span><span class="n">tablename</span><span class="w"> </span>
|
|
<span class="k">group</span><span class="w"> </span><span class="k">by</span><span class="w"> </span><span class="n">xc_node_id</span><span class="w"> </span>
|
|
<span class="k">order</span><span class="w"> </span><span class="k">by</span><span class="w"> </span><span class="n">xc_node_id</span><span class="w"> </span><span class="k">desc</span><span class="p">;</span>
|
|
</pre></div></td></tr></table></div>
|
|
</div>
|
|
<p id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_p173751945154918"><strong id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_b86686435641914">xc_node_id</strong> corresponds to a DN. Generally, <strong id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_b152523938841914">over 5% difference between the amount of data on different DNs is regarded as data skew. If the difference is over 10%, choose another distribution key.</strong></p>
|
|
</li><li id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_li796918294492">You are not advised to add a column as a distribution key, especially add a new column and use the SEQUENCE value to fill the column. (Sequences may cause performance bottlenecks and unnecessary maintenance costs.)</li></ol>
|
|
<div class="section" id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_section1984244714715"><h4 class="sectiontitle">View the data in the table.</h4><ul id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_u07b62e23ad344ae2ba2fc1e41ecb8257"><li id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_en-us_topic_0059777600_li85554471236">Run the following command to query information about all tables in a database in the system catalog <strong id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_b104632650041914">pg_tables</strong>:<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_sdfa482afeb1940c487495c3511cfa6d7"><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">pg_tables</span><span class="p">;</span>
|
|
</pre></div></td></tr></table></div>
|
|
</div>
|
|
</li><li id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_l2d3b500f79a3465b8d7432074f9c9891">Run the <strong id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_b139737454941914">\d+</strong> command of the <strong id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_b205780356341914">gsql</strong> tool to query table attributes:<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_s0bc9c01964cd4e739297284c2c53f0cc"><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="n">d</span><span class="o">+</span><span class="w"> </span><span class="n">customer_t1</span><span class="p">;</span>
|
|
</pre></div></td></tr></table></div>
|
|
</div>
|
|
</li><li id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_lc862b99aef1d48bc90968ea2cae0104a">Run the following command to query the data volume of table <strong id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_b210203128841914">customer_t1</strong>:<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_s46bb518e5cac4861bb959f20aac1c72c"><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="k">count</span><span class="p">(</span><span class="o">*</span><span class="p">)</span><span class="w"> </span><span class="k">FROM</span><span class="w"> </span><span class="n">customer_t1</span><span class="p">;</span>
|
|
</pre></div></td></tr></table></div>
|
|
</div>
|
|
</li><li id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_en-us_topic_0059777600_li79820101157">Run the following command to query all data in table <strong id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_b82951724941914">customer_t1</strong>:<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_s3ef473fe86dc4c6b97187561a3720db1"><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">customer_t1</span><span class="p">;</span>
|
|
</pre></div></td></tr></table></div>
|
|
</div>
|
|
</li><li id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_l5d2d4c66a50b49d6977a74e5c9d31d74">Run the following command to query data in column <strong id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_b201884264941914">c_customer_sk</strong>:<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_s9a9e4c1a3ce54791ac960b4dbeff7db6"><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="n">c_customer_sk</span><span class="w"> </span><span class="k">FROM</span><span class="w"> </span><span class="n">customer_t1</span><span class="p">;</span>
|
|
</pre></div></td></tr></table></div>
|
|
</div>
|
|
</li><li id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_l60f8ffb5ca32471598e9883d54e7335f">Run the following command to filter repeated data in column <strong id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_b81545117741914">c_customer_sk</strong>:<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_s46de14153b6f4cecbb5a9efb1d6cb2fa"><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="k">DISTINCT</span><span class="p">(</span><span class="w"> </span><span class="n">c_customer_sk</span><span class="w"> </span><span class="p">)</span><span class="w"> </span><span class="k">FROM</span><span class="w"> </span><span class="n">customer_t1</span><span class="p">;</span>
|
|
</pre></div></td></tr></table></div>
|
|
</div>
|
|
</li><li id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_l69738d7701504355acbc58a2fc2e5f66">Run the following command to query all data whose column <strong id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_b199114775941914">c_customer_sk</strong> is <strong id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_b16741359341914">3869</strong>:<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_s5903b09f43ed49a5a429cfc753a8e423"><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">customer_t1</span><span class="w"> </span><span class="k">WHERE</span><span class="w"> </span><span class="n">c_customer_sk</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">3869</span><span class="p">;</span>
|
|
</pre></div></td></tr></table></div>
|
|
</div>
|
|
</li><li id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_l2d1851e245ce4b129f70b0dd8db837e2">Run the following command to sort data based on column <strong id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_b198768264441914">c_customer_sk</strong>.<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_s5465cdc8733e4ec89764fb192d0753a7"><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">customer_t1</span><span class="w"> </span><span class="k">ORDER</span><span class="w"> </span><span class="k">BY</span><span class="w"> </span><span class="n">c_customer_sk</span><span class="p">;</span>
|
|
</pre></div></td></tr></table></div>
|
|
</div>
|
|
</li></ul>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_section2098516361488"><h4 class="sectiontitle">Deleting Data in a Table</h4><div class="caution" id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_note8755933132018"><span class="cautiontitle"><img src="public_sys-resources/caution_3.0-en-us.png"> </span><div class="cautionbody"><p id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_p6923333151416">Exercise caution when running the <strong id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_b20949123473">DROP TABLE</strong> and <strong id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_b198281314124712">TRUNCATE TABLE</strong> statements. After a table is deleted, data cannot be restored.</p>
|
|
</div></div>
|
|
<ul id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_ul1484419214133"><li id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_li1184418215137">Delete the <strong id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_b2058202584711">customer_t1</strong> table from the database.<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_screen1084482119137"><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">DROP</span><span class="w"> </span><span class="k">TABLE</span><span class="w"> </span><span class="n">customer_t1</span><span class="p">;</span>
|
|
</pre></div></td></tr></table></div>
|
|
</div>
|
|
</li><li id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_li128955618152">You can use <strong id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_b7418113294715">DELETE</strong> or <strong id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_b593663564716">TRUNCATE</strong> to clear rows in a table without removing the definition of the table.<div class="p" id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_p931584315264">Delete all rows from the <strong id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_b1910134314719">customer_t1</strong> table.<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_screen46451224131512"><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">TRUNCATE</span><span class="w"> </span><span class="k">TABLE</span><span class="w"> </span><span class="n">customer_t1</span><span class="p">;</span>
|
|
</pre></div></td></tr></table></div>
|
|
</div>
|
|
</div>
|
|
<div class="p" id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_p2090911811170">Delete all rows from the <strong id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_b0328550164715">customer_t1</strong> table.<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_s2a09ff28fcc54aa7b046ad807ae4da71"><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">DELETE</span><span class="w"> </span><span class="k">FROM</span><span class="w"> </span><span class="n">customer_t1</span><span class="p">;</span>
|
|
</pre></div></td></tr></table></div>
|
|
</div>
|
|
</div>
|
|
<div class="p" id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_p61992010265">Delete all records whose <strong id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_b759111010487">c_customer_sk</strong> is <strong id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_b118551355174714">3869</strong> from the <strong id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_b173595624815">customer_t1</strong> table.<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001510522721__en-us_topic_0000001233681653_sfa0b870201404af5a1123af7844f4937"><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">DELETE</span><span class="w"> </span><span class="k">FROM</span><span class="w"> </span><span class="n">customer_t1</span><span class="w"> </span><span class="k">WHERE</span><span class="w"> </span><span class="n">c_customer_sk</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">3869</span><span class="p">;</span>
|
|
</pre></div></td></tr></table></div>
|
|
</div>
|
|
</div>
|
|
</li></ul>
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<div class="familylinks">
|
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="dws_04_0016.html">Defining Database Objects</a></div>
|
|
</div>
|
|
</div>
|
|
|