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

68 lines
7.7 KiB
HTML

<a name="EN-US_TOPIC_0000001772696160"></a><a name="EN-US_TOPIC_0000001772696160"></a>
<h1 class="topictitle1">Set Types</h1>
<div id="body8662426"><div class="section" id="EN-US_TOPIC_0000001772696160__en-us_topic_0000001706224229_en-us_topic_0000001433628841_section164812323252"><h4 class="sectiontitle">Overview</h4><ol id="EN-US_TOPIC_0000001772696160__en-us_topic_0000001706224229_en-us_topic_0000001433628841_en-us_topic_0214164602_ol165921580410"><li id="EN-US_TOPIC_0000001772696160__en-us_topic_0000001706224229_en-us_topic_0000001433628841_en-us_topic_0214164602_li959275819413">In MySQL, an ENUM is a string object with a value chosen from a list of permitted values that are enumerated explicitly in the column specification at table creation.</li><li id="EN-US_TOPIC_0000001772696160__en-us_topic_0000001706224229_en-us_topic_0000001433628841_en-us_topic_0214164602_li2083411211510">A SET is a string object that can have zero or more values, each of which must be chosen from a list of permitted values specified when the table is created.</li></ol>
</div>
<div class="section" id="EN-US_TOPIC_0000001772696160__en-us_topic_0000001706224229_en-us_topic_0000001433628841_section1448194415256"><h4 class="sectiontitle">Type Mapping</h4>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="EN-US_TOPIC_0000001772696160__en-us_topic_0000001706224229_en-us_topic_0000001433628841_en-us_topic_0214164519_table10307949615" frame="border" border="1" rules="all"><caption><b>Table 1 </b>Set type mapping</caption><thead align="left"><tr id="EN-US_TOPIC_0000001772696160__en-us_topic_0000001706224229_en-us_topic_0000001433628841_en-us_topic_0214164519_row83071941461"><th align="left" class="cellrowborder" valign="top" width="33.33333333333333%" id="mcps1.3.2.2.2.4.1.1"><p id="EN-US_TOPIC_0000001772696160__en-us_topic_0000001706224229_en-us_topic_0000001433628841_en-us_topic_0214164519_p230710412620">MySQL Set Type</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="33.33333333333333%" id="mcps1.3.2.2.2.4.1.2"><p id="EN-US_TOPIC_0000001772696160__en-us_topic_0000001706224229_en-us_topic_0000001433628841_en-us_topic_0214164519_p12307141365">MySQL INPUT</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="33.33333333333333%" id="mcps1.3.2.2.2.4.1.3"><p id="EN-US_TOPIC_0000001772696160__en-us_topic_0000001706224229_en-us_topic_0000001433628841_en-us_topic_0214164519_p1030714262">GaussDB(DWS) OUTPUT</p>
</th>
</tr>
</thead>
<tbody><tr id="EN-US_TOPIC_0000001772696160__en-us_topic_0000001706224229_en-us_topic_0000001433628841_en-us_topic_0214164519_row2307945620"><td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.3.2.2.2.4.1.1 "><p id="EN-US_TOPIC_0000001772696160__en-us_topic_0000001706224229_en-us_topic_0000001433628841_en-us_topic_0214164519_p9307341361">ENUM</p>
</td>
<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.3.2.2.2.4.1.2 "><p id="EN-US_TOPIC_0000001772696160__en-us_topic_0000001706224229_en-us_topic_0000001433628841_en-us_topic_0214164519_p9307541619">ENUM</p>
</td>
<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.3.2.2.2.4.1.3 "><p id="EN-US_TOPIC_0000001772696160__en-us_topic_0000001706224229_en-us_topic_0000001433628841_en-us_topic_0214164519_p43071441662">VARCHAR</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001772696160__en-us_topic_0000001706224229_en-us_topic_0000001433628841_en-us_topic_0214164519_row153085420614"><td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.3.2.2.2.4.1.1 "><p id="EN-US_TOPIC_0000001772696160__en-us_topic_0000001706224229_en-us_topic_0000001433628841_en-us_topic_0214164519_p4308114562">SET</p>
</td>
<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.3.2.2.2.4.1.2 "><p id="EN-US_TOPIC_0000001772696160__en-us_topic_0000001706224229_en-us_topic_0000001433628841_en-us_topic_0214164519_p3308841666">SET</p>
</td>
<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.3.2.2.2.4.1.3 "><p id="EN-US_TOPIC_0000001772696160__en-us_topic_0000001706224229_en-us_topic_0000001433628841_en-us_topic_0214164519_p173083420617">VARCHAR</p>
</td>
</tr>
</tbody>
</table>
</div>
<div class="note" id="EN-US_TOPIC_0000001772696160__en-us_topic_0000001706224229_en-us_topic_0000001433628841_en-us_topic_0214164385_note1544699172110"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><ul id="EN-US_TOPIC_0000001772696160__en-us_topic_0000001706224229_en-us_topic_0000001433628841_ul437662813153"><li id="EN-US_TOPIC_0000001772696160__en-us_topic_0000001706224229_en-us_topic_0000001433628841_li237602801512">The ENUM type is converted to the VARCHAR type. The precision is four times the length of the longest field in the enumerated values. Use the CHECK() function to ensure that the input enumerated values are correct.</li><li id="EN-US_TOPIC_0000001772696160__en-us_topic_0000001706224229_en-us_topic_0000001433628841_li1437702815152">The SET type is converted to the VARCHAR type. The precision is four times the sum of the length of each enumerated value field and the number of separators.</li></ul>
</div></div>
<p id="EN-US_TOPIC_0000001772696160__en-us_topic_0000001706224229_en-us_topic_0000001433628841_en-us_topic_0214164519_p10251501083"><strong id="EN-US_TOPIC_0000001772696160__en-us_topic_0000001706224229_en-us_topic_0000001433628841_b86542326231717">Input: ENUM</strong></p>
<pre class="screen" id="EN-US_TOPIC_0000001772696160__en-us_topic_0000001706224229_en-us_topic_0000001433628841_en-us_topic_0214164519_screen198514121388">CREATE TABLE IF NOT EXISTS `runoob_dataType_test`(
id int(2) PRIMARY KEY,
`dataType_17` ENUM('dws-1', 'dws-2', 'dws-3')
);</pre>
<p id="EN-US_TOPIC_0000001772696160__en-us_topic_0000001706224229_en-us_topic_0000001433628841_en-us_topic_0214164519_p203432231188"><strong id="EN-US_TOPIC_0000001772696160__en-us_topic_0000001706224229_en-us_topic_0000001433628841_en-us_topic_0214164519_b195396311081">Output</strong></p>
<pre class="screen" id="EN-US_TOPIC_0000001772696160__en-us_topic_0000001706224229_en-us_topic_0000001433628841_en-us_topic_0214164519_screen1871773318816">CREATE TABLE IF NOT EXISTS "public"."runoob_datatype_test"
(
"id" INTEGER(2) PRIMARY KEY,
"datatype_17" VARCHAR(20) CHECK (dataType_17 IN('dws-1','dws-2','dws-3','', null))
)
WITH ( ORIENTATION = ROW, COMPRESSION = NO )
NOCOMPRESS
DISTRIBUTE BY HASH ("id");</pre>
<p id="EN-US_TOPIC_0000001772696160__en-us_topic_0000001706224229_en-us_topic_0000001433628841_en-us_topic_0214164519_p996313591480"><strong id="EN-US_TOPIC_0000001772696160__en-us_topic_0000001706224229_en-us_topic_0000001433628841_b86536782031717">Input: SET</strong></p>
<pre class="screen" id="EN-US_TOPIC_0000001772696160__en-us_topic_0000001706224229_en-us_topic_0000001433628841_en-us_topic_0214164519_screen1010119234919">CREATE TABLE IF NOT EXISTS `runoob_tbl_test`(
`dataType_18` SET('dws-1', 'dws-2', 'dws-3')
);</pre>
<p id="EN-US_TOPIC_0000001772696160__en-us_topic_0000001706224229_en-us_topic_0000001433628841_en-us_topic_0214164519_p14992203111018"><strong id="EN-US_TOPIC_0000001772696160__en-us_topic_0000001706224229_en-us_topic_0000001433628841_en-us_topic_0214164519_b105611011121019">Output</strong></p>
<pre class="screen" id="EN-US_TOPIC_0000001772696160__en-us_topic_0000001706224229_en-us_topic_0000001433628841_en-us_topic_0214164519_screen6915144108">CREATE TABLE IF NOT EXISTS "public"."runoob_tbl_test"
(
"datatype_18" VARCHAR(68)
)
WITH ( ORIENTATION = ROW, COMPRESSION = NO )
NOCOMPRESS
DISTRIBUTE BY HASH ("datatype_18");</pre>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="dws_16_0106.html">Data Types</a></div>
</div>
</div>