Yang, Tong 48706b7552 MRS COMP-LTS 320-lts.1 version
Reviewed-by: Kacur, Michal <michal.kacur@t-systems.com>
Co-authored-by: Yang, Tong <yangtong2@huawei.com>
Co-committed-by: Yang, Tong <yangtong2@huawei.com>
2024-04-12 12:51:10 +00:00

48 lines
4.4 KiB
HTML

<a name="mrs_01_24503"></a><a name="mrs_01_24503"></a>
<h1 class="topictitle1">Changing the Column Name</h1>
<div id="body0000001584875113"><div class="section" id="mrs_01_24503__en-us_topic_0265792790_sa1cb229bf26b4a7a8efd1716defb63de"><h4 class="sectiontitle">Function</h4><p id="mrs_01_24503__en-us_topic_0265792790_ac917e6d6e78044e99179c0e0f5284232">The <strong id="mrs_01_24503__b978831612370">ALTER TABLE ... RENAME COLUMN</strong> command is used to change the column name.</p>
</div>
<div class="section" id="mrs_01_24503__en-us_topic_0265792790_sc019b10a59e9426498a678c024d74f03"><h4 class="sectiontitle">Syntax</h4><p id="mrs_01_24503__p115411424114818"><strong id="mrs_01_24503__b5541132404813">ALTER TABLE<em id="mrs_01_24503__i4403194212340"> </em></strong><em id="mrs_01_24503__i6434757143418">tableName</em><strong id="mrs_01_24503__b1059115111351"> RENAME COLUMN </strong><em id="mrs_01_24503__i19648627161118">old_columnName</em><strong id="mrs_01_24503__b1852112811112"> TO </strong><em id="mrs_01_24503__i2649122719111">new_columnName</em></p>
</div>
<div class="section" id="mrs_01_24503__en-us_topic_0265792790_s253f086de08745ac890027c0b103cd7a"><h4 class="sectiontitle">Parameter Description</h4>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="mrs_01_24503__en-us_topic_0265792790_ta69e9ecdc1554375a8a1e844b14e00c5" frame="border" border="1" rules="all"><caption><b>Table 1 </b>RENAME COLUMN parameters</caption><thead align="left"><tr id="mrs_01_24503__en-us_topic_0265792790_r61ddb6139b8d4f4ca4a88c6389f8f327"><th align="left" class="cellrowborder" valign="top" width="30%" id="mcps1.3.3.2.2.3.1.1"><p id="mrs_01_24503__en-us_topic_0265792790_aeb0bfa560fb74f1f9e584cc1ef05bb9b">Parameter</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="70%" id="mcps1.3.3.2.2.3.1.2"><p id="mrs_01_24503__en-us_topic_0265792790_ae81789e97e6d4953a8342f22d64feea9">Description</p>
</th>
</tr>
</thead>
<tbody><tr id="mrs_01_24503__en-us_topic_0265792790_r4a578c7015ba461bab46a5c40c46256a"><td class="cellrowborder" valign="top" width="30%" headers="mcps1.3.3.2.2.3.1.1 "><p id="mrs_01_24503__en-us_topic_0265792790_ac25da7f69c964d93947693ed5b4006cb">tableName</p>
</td>
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.3.3.2.2.3.1.2 "><p id="mrs_01_24503__en-us_topic_0265792790_a09288a5af7f44e36922b37de34446d94">Table name.</p>
</td>
</tr>
<tr id="mrs_01_24503__row8907155215817"><td class="cellrowborder" valign="top" width="30%" headers="mcps1.3.3.2.2.3.1.1 "><p id="mrs_01_24503__p89092524588">old_columnName</p>
</td>
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.3.3.2.2.3.1.2 "><p id="mrs_01_24503__p590945210588">Old column name.</p>
</td>
</tr>
<tr id="mrs_01_24503__row15665727106"><td class="cellrowborder" valign="top" width="30%" headers="mcps1.3.3.2.2.3.1.1 "><p id="mrs_01_24503__p066682111016">new_columnName</p>
</td>
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.3.3.2.2.3.1.2 "><p id="mrs_01_24503__p1166615241017">New column name.</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="section" id="mrs_01_24503__en-us_topic_0265792790_s55536c9c534643ed8272f9f4b47fb407"><h4 class="sectiontitle">Example</h4><pre class="screen" id="mrs_01_24503__screen5406192853515">ALTER TABLE table1 RENAME COLUMN a.b.c TO x</pre>
<p id="mrs_01_24503__p6315240121016"><strong id="mrs_01_24503__b596336468">a.b.c</strong> indicates the full path of a nested column. For details about the nested column rules, see <a href="mrs_01_24498.html">Adding a Column</a>.</p>
<div class="note" id="mrs_01_24503__note0326321103312"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="mrs_01_24503__p5327172163317">After the column name is changed, the change is automatically synchronized to the column comment. The comment is in <strong id="mrs_01_24503__b1369013421518">rename oldName to newName</strong> format.</p>
</div></div>
</div>
<div class="section" id="mrs_01_24503__en-us_topic_0265792790_sbd5eea8637c94038bf6a129ab9ca129f"><h4 class="sectiontitle">Response</h4><p id="mrs_01_24503__en-us_topic_0265792790_ab3f2ebd199c342fb9103cbe4f02c7148">You can run the <strong id="mrs_01_24503__b95190391964">DESCRIBE</strong> command to view the new column name.</p>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="mrs_01_24495.html">SparkSQL Schema Evolution and Syntax Description</a></div>
</div>
</div>