doc-exports/docs/dws/tool/dws_16_0161.html
Lu, Huayi 27019c2991 DWS TOOL 830.201 version
Reviewed-by: Hasko, Vladimir <vladimir.hasko@t-systems.com>
Reviewed-by: Pruthi, Vineet <vineet.pruthi@t-systems.com>
Co-authored-by: Lu, Huayi <luhuayi@huawei.com>
Co-committed-by: Lu, Huayi <luhuayi@huawei.com>
2024-05-16 07:35:25 +00:00

40 lines
4.8 KiB
HTML

<a name="EN-US_TOPIC_0000001819336217"></a><a name="EN-US_TOPIC_0000001819336217"></a>
<h1 class="topictitle1">RENAME (Table Renaming)</h1>
<div id="body8662426"><p id="EN-US_TOPIC_0000001819336217__en-us_topic_0000001706105041_en-us_topic_0000001436175741_en-us_topic_0214164669_p11532411115112">The statement for renaming a table in MySQL is slightly different from that in GaussDB(DWS). DSC will perform adaptation based on GaussDB(DWS) features during migration.</p>
<div class="caution" id="EN-US_TOPIC_0000001819336217__en-us_topic_0000001706105041_en-us_topic_0000001436175741_en-us_topic_0214164669_note4707640687"><span class="cautiontitle"><img src="public_sys-resources/caution_3.0-en-us.png"> </span><div class="cautionbody"><p id="EN-US_TOPIC_0000001819336217__en-us_topic_0000001706105041_en-us_topic_0000001436175741_en-us_topic_0214164669_p71171916121011">Currently, DSC does not support original table names prefixed with <strong id="EN-US_TOPIC_0000001819336217__en-us_topic_0000001706105041_en-us_topic_0000001436175741_b95230114632239">DATABASE/SCHEMA.</strong></p>
</div></div>
<ol id="EN-US_TOPIC_0000001819336217__en-us_topic_0000001706105041_en-us_topic_0000001436175741_en-us_topic_0214164669_ol33447017537"><li id="EN-US_TOPIC_0000001819336217__en-us_topic_0000001706105041_en-us_topic_0000001436175741_en-us_topic_0214164669_li163456014530">MySQL uses the <strong id="EN-US_TOPIC_0000001819336217__en-us_topic_0000001706105041_en-us_topic_0000001436175741_b98409559732239">RENAME TABLE</strong> statement to change a table name.<p id="EN-US_TOPIC_0000001819336217__en-us_topic_0000001706105041_en-us_topic_0000001436175741_en-us_topic_0214164669_p1227645615546"><strong id="EN-US_TOPIC_0000001819336217__en-us_topic_0000001706105041_en-us_topic_0000001436175741_en-us_topic_0214164669_b13730218125518">Input</strong></p>
<pre class="screen" id="EN-US_TOPIC_0000001819336217__en-us_topic_0000001706105041_en-us_topic_0000001436175741_en-us_topic_0214164669_screen10792151117551"># Rename a single table.
RENAME TABLE DEPARTMENT TO NEWDEPT;
# Rename multiple tables.
RENAME TABLE NEWDEPT TO NEWDEPT_02,PEOPLE TO PEOPLE_02;</pre>
<p id="EN-US_TOPIC_0000001819336217__en-us_topic_0000001706105041_en-us_topic_0000001436175741_en-us_topic_0214164669_p43776225514"><strong id="EN-US_TOPIC_0000001819336217__en-us_topic_0000001706105041_en-us_topic_0000001436175741_en-us_topic_0214164669_b676292065518">Output</strong></p>
<pre class="screen" id="EN-US_TOPIC_0000001819336217__en-us_topic_0000001706105041_en-us_topic_0000001436175741_en-us_topic_0214164669_screen11734201310552">-- Rename a single table.
ALTER TABLE "public"."department" RENAME TO "newdept";
-- Rename multiple tables.
ALTER TABLE "public"."newdept" RENAME TO "newdept_02";
ALTER TABLE "public"."people" RENAME TO "people_02";</pre>
</li><li id="EN-US_TOPIC_0000001819336217__en-us_topic_0000001706105041_en-us_topic_0000001436175741_en-us_topic_0214164669_li141013269533">In MySQL, the <strong id="EN-US_TOPIC_0000001819336217__en-us_topic_0000001706105041_en-us_topic_0000001436175741_b752115515298">ALTER TABLE RENAME</strong> statement is used to change a table name. When this statement is migrated by DSC, the keyword <strong id="EN-US_TOPIC_0000001819336217__en-us_topic_0000001706105041_en-us_topic_0000001436175741_b10522165122916">AS</strong> is converted to <strong id="EN-US_TOPIC_0000001819336217__en-us_topic_0000001706105041_en-us_topic_0000001436175741_b9523051192913">TO</strong>.<p id="EN-US_TOPIC_0000001819336217__en-us_topic_0000001706105041_en-us_topic_0000001436175741_en-us_topic_0214164669_p6513192815515"><strong id="EN-US_TOPIC_0000001819336217__en-us_topic_0000001706105041_en-us_topic_0000001436175741_en-us_topic_0214164669_b9513128175513">Input</strong></p>
<pre class="screen" id="EN-US_TOPIC_0000001819336217__en-us_topic_0000001706105041_en-us_topic_0000001436175741_en-us_topic_0214164669_screen151315280557">## A.
ALTER TABLE runoob_alter_test RENAME TO runoob_alter_testnew;
## B.
ALTER TABLE runoob_alter_testnew RENAME AS runoob_alter_testnewnew;</pre>
<p id="EN-US_TOPIC_0000001819336217__en-us_topic_0000001706105041_en-us_topic_0000001436175741_en-us_topic_0214164669_p16513132825519"><strong id="EN-US_TOPIC_0000001819336217__en-us_topic_0000001706105041_en-us_topic_0000001436175741_en-us_topic_0214164669_b251316289553">Output</strong></p>
<pre class="screen" id="EN-US_TOPIC_0000001819336217__en-us_topic_0000001706105041_en-us_topic_0000001436175741_en-us_topic_0214164669_screen1513228105515">-- A.
ALTER TABLE "public"."runoob_alter_test" RENAME TO "runoob_alter_testnew";
-- B.
ALTER TABLE "public"."runoob_alter_testnew" RENAME TO "runoob_alter_testnewnew";</pre>
</li></ol>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="dws_16_0119.html">Table (Optional Parameters and Operations)</a></div>
</div>
</div>