forked from docs/doc-exports
Reviewed-by: Hasko, Vladimir <vladimir.hasko@t-systems.com> Co-authored-by: Lu, Huayi <luhuayi@huawei.com> Co-committed-by: Lu, Huayi <luhuayi@huawei.com>
39 lines
5.8 KiB
HTML
39 lines
5.8 KiB
HTML
<a name="EN-US_TOPIC_0000001098670820"></a><a name="EN-US_TOPIC_0000001098670820"></a>
|
|
|
|
<h1 class="topictitle1">EXECUTE DIRECT</h1>
|
|
<div id="body8662426"><div class="section" id="EN-US_TOPIC_0000001098670820__scb5938ca9b7c485ca021e0b798d0b9b6"><h4 class="sectiontitle">Function</h4><p id="EN-US_TOPIC_0000001098670820__a9c085daa06db4f36a477be962c5b7c06"><strong id="EN-US_TOPIC_0000001098670820__b585565489558_1">EXECUTE DIRECT</strong> executes an SQL statement on a specified node. Generally, the cluster automatically allocates an SQL statement to proper nodes. <strong id="EN-US_TOPIC_0000001098670820__b84235270683846">EXECUTE DIRECT</strong> is mainly used for database maintenance and testing.</p>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001098670820__s55bcbd7c04aa412cbb9a9f14d708b947"><h4 class="sectiontitle">Precautions</h4><ul id="EN-US_TOPIC_0000001098670820__ul79761746145217"><li id="EN-US_TOPIC_0000001098670820__li1745195132414">Only a system administrator can run the <strong id="EN-US_TOPIC_0000001098670820__b842352706114312">EXECUTE DIRECT</strong> statement.</li><li id="EN-US_TOPIC_0000001098670820__li16976124615220">To ensure data consistency across nodes, only the <strong id="EN-US_TOPIC_0000001098670820__b84235270683930">SELECT</strong> statement can be used. Transaction statements, DDL, and DML cannot be used.</li><li id="EN-US_TOPIC_0000001098670820__li156289576525">When the AVG aggregation calculation is performed on the specified DN using such statements, the result set is returned in array, for example, {4,2}. The result of sum is 4, and that of count is 2.</li><li id="EN-US_TOPIC_0000001098670820__li69601568438">Do not run the <strong id="EN-US_TOPIC_0000001098670820__b1541410324558">SELECT</strong> statement on nodes where CNs reside because user table data is not stored there.</li><li id="EN-US_TOPIC_0000001098670820__li360267184620"><strong id="EN-US_TOPIC_0000001098670820__b364819401695">EXECUTE DIRECT</strong> cannot be nested. If the inner SQL statement to be executed is also <strong id="EN-US_TOPIC_0000001098670820__b178035146163">EXECUTE DIRECT</strong>, run only the bottom-layer <strong id="EN-US_TOPIC_0000001098670820__b1672572812163">EXECUTE DIRECT</strong> statement.</li></ul>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001098670820__saea998a246df4d51a51fa2a854eab93a"><h4 class="sectiontitle">Syntax</h4><div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001098670820__s496d2f47f4ae48b0ad0f9afa1e18f594"><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">EXECUTE</span><span class="w"> </span><span class="n">DIRECT</span><span class="w"> </span><span class="k">ON</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="n">query</span><span class="w"> </span><span class="p">;</span><span class="w"></span>
|
|
</pre></div></td></tr></table></div>
|
|
|
|
</div>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001098670820__sef734b80b4234f9696610d718960f24f"><h4 class="sectiontitle">Parameter Description</h4><ul id="EN-US_TOPIC_0000001098670820__u98f0aa2e2ba246af9d5fa4023afd0771"><li id="EN-US_TOPIC_0000001098670820__le566e2bbd36540f1bd475212a469d9c4"><strong id="EN-US_TOPIC_0000001098670820__a1329e0b5df29496c9db2d60c2775f640">nodename</strong><p id="EN-US_TOPIC_0000001098670820__a39709549c16b44e5ae7b75bc19293906">Specifies the node name.</p>
|
|
<p id="EN-US_TOPIC_0000001098670820__a9823c1f59d1746a190f8a4bb6988192e">Value range: An existing node.</p>
|
|
</li><li id="EN-US_TOPIC_0000001098670820__l8ceb2f6282784642b6cdc3ad5d015732"><strong id="EN-US_TOPIC_0000001098670820__a5623d031dcce49b6ba8a79c261ee385f">query</strong><p id="EN-US_TOPIC_0000001098670820__a075087218773492e82b18bd3b3ce7f68">Specifies the query SQL statement that you want to execute.</p>
|
|
</li></ul>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001098670820__s63bfb86eaf644a41be0a104363fbaafb"><h4 class="sectiontitle">Examples</h4><p id="EN-US_TOPIC_0000001098670820__p96305590452">Query records in table <strong id="EN-US_TOPIC_0000001098670820__b204211113455"><span id="EN-US_TOPIC_0000001098670820__text167105285289">tpcds.</span>customer_address</strong> on the dn_6001_6002 node.</p>
|
|
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001098670820__screen143205249466"><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">EXECUTE</span><span class="w"> </span><span class="n">DIRECT</span><span class="w"> </span><span class="k">ON</span><span class="p">(</span><span class="n">dn_6001_6002</span><span class="p">)</span><span class="w"> </span><span class="s1">'select count(*) from tpcds.customer_address'</span><span class="p">;</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">count</span><span class="w"> </span>
|
|
<span class="c1">-------</span>
|
|
<span class="w"> </span><span class="mi">16922</span><span class="w"></span>
|
|
<span class="p">(</span><span class="mi">1</span><span class="w"> </span><span class="k">row</span><span class="p">)</span><span class="w"></span>
|
|
</pre></div></td></tr></table></div>
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<div class="familylinks">
|
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="dws_06_0242.html">DCL Syntax</a></div>
|
|
</div>
|
|
</div>
|
|
|