doc-exports/docs/dws/tool/dws_16_0163.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

58 lines
5.4 KiB
HTML

<a name="EN-US_TOPIC_0000001772536532"></a><a name="EN-US_TOPIC_0000001772536532"></a>
<h1 class="topictitle1">Renaming a Column</h1>
<div id="body8662426"><div class="section" id="EN-US_TOPIC_0000001772536532__en-us_topic_0000001657865582_en-us_topic_0000001397279084_section11961234133818"><h4 class="sectiontitle">Using a Reserved Keyword As a Column Name</h4><p id="EN-US_TOPIC_0000001772536532__en-us_topic_0000001657865582_en-us_topic_0000001397279084_p68161834113915">In GaussDB(DWS), reserved keywords must be enclosed in double quotation marks when they are used as column names. The following reserved keywords are supported: desc, checksum, operator, and size.</p>
<p id="EN-US_TOPIC_0000001772536532__en-us_topic_0000001657865582_en-us_topic_0000001397279084_p1449419509418"><strong id="EN-US_TOPIC_0000001772536532__en-us_topic_0000001657865582_en-us_topic_0000001397279084_b146981227428">Input</strong></p>
<pre class="screen" id="EN-US_TOPIC_0000001772536532__en-us_topic_0000001657865582_en-us_topic_0000001397279084_screen188983454319">create table `desc` (
user char,
checksum int,
operator smallint,
desc char,
size bigint
);
drop table if exists `desc`;</pre>
<p id="EN-US_TOPIC_0000001772536532__en-us_topic_0000001657865582_en-us_topic_0000001397279084_p439699164315"><strong id="EN-US_TOPIC_0000001772536532__en-us_topic_0000001657865582_en-us_topic_0000001397279084_b1874825164318">Output</strong></p>
<pre class="screen" id="EN-US_TOPIC_0000001772536532__en-us_topic_0000001657865582_en-us_topic_0000001397279084_screen147551719194316">CREATE TABLE "public"."desc" (
"user" CHAR(4),
"checksum" INTEGER,
"operator" SMALLINT,
"desc" CHAR(4),
"size" BIGINT
) WITH (ORIENTATION = ROW, COMPRESSION = NO) NOCOMPRESS DISTRIBUTE BY HASH ("user");</pre>
</div>
<div class="section" id="EN-US_TOPIC_0000001772536532__en-us_topic_0000001657865582_en-us_topic_0000001397279084_section1840153763916"><h4 class="sectiontitle">Using the Name of a Hidden Column of a System Catalog As a Column Name</h4><p id="EN-US_TOPIC_0000001772536532__en-us_topic_0000001657865582_en-us_topic_0000001397279084_p191614582394">If the defined column name is the same as that of a hidden column in a GaussDB(DWS) system catalog ( including <strong id="EN-US_TOPIC_0000001772536532__en-us_topic_0000001657865582_en-us_topic_0000001397279084_b128369149179">xc_node_id</strong> and <strong id="EN-US_TOPIC_0000001772536532__en-us_topic_0000001657865582_en-us_topic_0000001397279084_b101941219181714">tableoid</strong>, <strong id="EN-US_TOPIC_0000001772536532__en-us_topic_0000001657865582_en-us_topic_0000001397279084_b103432213171">cmax</strong>, <strong id="EN-US_TOPIC_0000001772536532__en-us_topic_0000001657865582_en-us_topic_0000001397279084_b6308424161711">xmax</strong>, <strong id="EN-US_TOPIC_0000001772536532__en-us_topic_0000001657865582_en-us_topic_0000001397279084_b16581172617178">cmin</strong>, <strong id="EN-US_TOPIC_0000001772536532__en-us_topic_0000001657865582_en-us_topic_0000001397279084_b10122182915174">xmin</strong>, <strong id="EN-US_TOPIC_0000001772536532__en-us_topic_0000001657865582_en-us_topic_0000001397279084_b1956914327176">ctid</strong>, <strong id="EN-US_TOPIC_0000001772536532__en-us_topic_0000001657865582_en-us_topic_0000001397279084_b174638364179">tid.</strong>), you need to rename the column. To rename the column, add <strong id="EN-US_TOPIC_0000001772536532__en-us_topic_0000001657865582_en-us_topic_0000001397279084_b4348435174">_new</strong> at the end. For example, change <strong id="EN-US_TOPIC_0000001772536532__en-us_topic_0000001657865582_en-us_topic_0000001397279084_b1739314651810">xc_node_id</strong> to <strong id="EN-US_TOPIC_0000001772536532__en-us_topic_0000001657865582_en-us_topic_0000001397279084_b3360181013183">xc_node_id_new</strong>.</p>
<p id="EN-US_TOPIC_0000001772536532__en-us_topic_0000001657865582_en-us_topic_0000001397279084_p712835684417"><strong id="EN-US_TOPIC_0000001772536532__en-us_topic_0000001657865582_en-us_topic_0000001397279084_b11771161610455">Input</strong></p>
<pre class="screen" id="EN-US_TOPIC_0000001772536532__en-us_topic_0000001657865582_en-us_topic_0000001397279084_screen964739124513">drop table if exists `renameFieldName`;
create table if not exists `renameFieldName`(
xc_node_id int,
tableoid char(3),
cmax smallint,
xmax bigint auto_increment,
cmin varchar(10),
xmin int,
ctid int auto_increment,
tid int
);
drop table if exists `renameFieldName`;</pre>
<p id="EN-US_TOPIC_0000001772536532__en-us_topic_0000001657865582_en-us_topic_0000001397279084_p981414459"><strong id="EN-US_TOPIC_0000001772536532__en-us_topic_0000001657865582_en-us_topic_0000001397279084_b843718195457">Output</strong></p>
<pre class="screen" id="EN-US_TOPIC_0000001772536532__en-us_topic_0000001657865582_en-us_topic_0000001397279084_screen1156413104513">DROP TABLE IF EXISTS "public"."renamefieldname";
CREATE TABLE IF NOT EXISTS "public"."renamefieldname" (
"xc_node_id_new" INTEGER,
"tableoid_new" CHAR(12),
"cmax_new" SMALLINT,
"xmax_new" BIGSERIAL,
"cmin_new" VARCHAR(40),
"xmin_new" INTEGER,
"ctid_new" SERIAL,
"tid_new" INTEGER
) WITH (ORIENTATION = ROW, COMPRESSION = NO) NOCOMPRESS DISTRIBUTE BY HASH ("xc_node_id_new");
DROP TABLE IF EXISTS "public"."renamefieldname";</pre>
</div>
</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>