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

158 lines
17 KiB
HTML

<a name="EN-US_TOPIC_0000001772536480"></a><a name="EN-US_TOPIC_0000001772536480"></a>
<h1 class="topictitle1">String Types</h1>
<div id="body8662426"><div class="section" id="EN-US_TOPIC_0000001772536480__en-us_topic_0000001706104857_en-us_topic_0000001383668660_section67087192316"><h4 class="sectiontitle">Overview</h4><p id="EN-US_TOPIC_0000001772536480__en-us_topic_0000001706104857_en-us_topic_0000001383668660_p20105165412127">MySQL interprets length specifications in character column definitions in character units. This applies to the CHAR, VARCHAR, and TEXT types. DSC supports the following type conversions:</p>
</div>
<div class="section" id="EN-US_TOPIC_0000001772536480__en-us_topic_0000001706104857_en-us_topic_0000001383668660_section2048541752316"><h4 class="sectiontitle">Type Mapping</h4>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="EN-US_TOPIC_0000001772536480__en-us_topic_0000001706104857_en-us_topic_0000001383668660_en-us_topic_0214164778_table4723653184710" frame="border" border="1" rules="all"><caption><b>Table 1 </b>String type mapping</caption><thead align="left"><tr id="EN-US_TOPIC_0000001772536480__en-us_topic_0000001706104857_en-us_topic_0000001383668660_en-us_topic_0214164778_row872415318474"><th align="left" class="cellrowborder" valign="top" width="19.99199919991999%" id="mcps1.3.2.2.2.4.1.1"><p id="EN-US_TOPIC_0000001772536480__en-us_topic_0000001706104857_en-us_topic_0000001383668660_en-us_topic_0214164778_p8724205317473">MySQL String Type</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="36.94369436943694%" id="mcps1.3.2.2.2.4.1.2"><p id="EN-US_TOPIC_0000001772536480__en-us_topic_0000001706104857_en-us_topic_0000001383668660_en-us_topic_0214164778_p17724553194715">MySQL INPUT</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="43.064306430643065%" id="mcps1.3.2.2.2.4.1.3"><p id="EN-US_TOPIC_0000001772536480__en-us_topic_0000001706104857_en-us_topic_0000001383668660_en-us_topic_0214164778_p1672435312473">GaussDB(DWS) OUTPUT</p>
</th>
</tr>
</thead>
<tbody><tr id="EN-US_TOPIC_0000001772536480__en-us_topic_0000001706104857_en-us_topic_0000001383668660_en-us_topic_0214164778_row14724165324710"><td class="cellrowborder" valign="top" width="19.99199919991999%" headers="mcps1.3.2.2.2.4.1.1 "><p id="EN-US_TOPIC_0000001772536480__en-us_topic_0000001706104857_en-us_topic_0000001383668660_en-us_topic_0214164778_p272455310476">CHAR</p>
</td>
<td class="cellrowborder" valign="top" width="36.94369436943694%" headers="mcps1.3.2.2.2.4.1.2 "><p id="EN-US_TOPIC_0000001772536480__en-us_topic_0000001706104857_en-us_topic_0000001383668660_en-us_topic_0214164778_p1172425354712">CHAR[(0)]</p>
<p id="EN-US_TOPIC_0000001772536480__en-us_topic_0000001706104857_en-us_topic_0000001383668660_p174111015316">CHAR[(n)]</p>
</td>
<td class="cellrowborder" valign="top" width="43.064306430643065%" headers="mcps1.3.2.2.2.4.1.3 "><p id="EN-US_TOPIC_0000001772536480__en-us_topic_0000001706104857_en-us_topic_0000001383668660_en-us_topic_0214164778_p572475319478">CHAR[(1)]</p>
<p id="EN-US_TOPIC_0000001772536480__en-us_topic_0000001706104857_en-us_topic_0000001383668660_p3447115145313">CHAR[(4n)]</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001772536480__en-us_topic_0000001706104857_en-us_topic_0000001383668660_row9749195618174"><td class="cellrowborder" valign="top" width="19.99199919991999%" headers="mcps1.3.2.2.2.4.1.1 "><p id="EN-US_TOPIC_0000001772536480__en-us_topic_0000001706104857_en-us_topic_0000001383668660_p1775075601713">CHARACTER</p>
</td>
<td class="cellrowborder" valign="top" width="36.94369436943694%" headers="mcps1.3.2.2.2.4.1.2 "><p id="EN-US_TOPIC_0000001772536480__en-us_topic_0000001706104857_en-us_topic_0000001383668660_p575018569175">CHARACTER[(0)]</p>
<p id="EN-US_TOPIC_0000001772536480__en-us_topic_0000001706104857_en-us_topic_0000001383668660_p36143355276">CHARACTER[(n)]</p>
</td>
<td class="cellrowborder" valign="top" width="43.064306430643065%" headers="mcps1.3.2.2.2.4.1.3 "><p id="EN-US_TOPIC_0000001772536480__en-us_topic_0000001706104857_en-us_topic_0000001383668660_p15750115651711">CHAR[(1)]</p>
<p id="EN-US_TOPIC_0000001772536480__en-us_topic_0000001706104857_en-us_topic_0000001383668660_p11609184592714">CHAR[(4n)]</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001772536480__en-us_topic_0000001706104857_en-us_topic_0000001383668660_row05416174418"><td class="cellrowborder" valign="top" width="19.99199919991999%" headers="mcps1.3.2.2.2.4.1.1 "><p id="EN-US_TOPIC_0000001772536480__en-us_topic_0000001706104857_en-us_topic_0000001383668660_p761216164414">NCHAR</p>
</td>
<td class="cellrowborder" valign="top" width="36.94369436943694%" headers="mcps1.3.2.2.2.4.1.2 "><p id="EN-US_TOPIC_0000001772536480__en-us_topic_0000001706104857_en-us_topic_0000001383668660_p56316184414">NCHAR[(0)]</p>
<p id="EN-US_TOPIC_0000001772536480__en-us_topic_0000001706104857_en-us_topic_0000001383668660_p431516715540">NCHAR[(n)]</p>
</td>
<td class="cellrowborder" valign="top" width="43.064306430643065%" headers="mcps1.3.2.2.2.4.1.3 "><p id="EN-US_TOPIC_0000001772536480__en-us_topic_0000001706104857_en-us_topic_0000001383668660_p6741618440">CHAR[(1)]</p>
<p id="EN-US_TOPIC_0000001772536480__en-us_topic_0000001706104857_en-us_topic_0000001383668660_p574300185511">CHAR[(4n)]</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001772536480__en-us_topic_0000001706104857_en-us_topic_0000001383668660_en-us_topic_0214164778_row1072485319474"><td class="cellrowborder" valign="top" width="19.99199919991999%" headers="mcps1.3.2.2.2.4.1.1 "><p id="EN-US_TOPIC_0000001772536480__en-us_topic_0000001706104857_en-us_topic_0000001383668660_en-us_topic_0214164778_p177242539473">LONGTEXT</p>
</td>
<td class="cellrowborder" valign="top" width="36.94369436943694%" headers="mcps1.3.2.2.2.4.1.2 "><p id="EN-US_TOPIC_0000001772536480__en-us_topic_0000001706104857_en-us_topic_0000001383668660_en-us_topic_0214164778_p77241953204716">LONGTEXT</p>
</td>
<td class="cellrowborder" valign="top" width="43.064306430643065%" headers="mcps1.3.2.2.2.4.1.3 "><p id="EN-US_TOPIC_0000001772536480__en-us_topic_0000001706104857_en-us_topic_0000001383668660_en-us_topic_0214164778_p15724105310475">TEXT</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001772536480__en-us_topic_0000001706104857_en-us_topic_0000001383668660_en-us_topic_0214164778_row1372435384716"><td class="cellrowborder" valign="top" width="19.99199919991999%" headers="mcps1.3.2.2.2.4.1.1 "><p id="EN-US_TOPIC_0000001772536480__en-us_topic_0000001706104857_en-us_topic_0000001383668660_en-us_topic_0214164778_p117241753184718">MEDIUMTEXT</p>
</td>
<td class="cellrowborder" valign="top" width="36.94369436943694%" headers="mcps1.3.2.2.2.4.1.2 "><p id="EN-US_TOPIC_0000001772536480__en-us_topic_0000001706104857_en-us_topic_0000001383668660_en-us_topic_0214164778_p127241253154714">MEDIUMTEXT</p>
</td>
<td class="cellrowborder" valign="top" width="43.064306430643065%" headers="mcps1.3.2.2.2.4.1.3 "><p id="EN-US_TOPIC_0000001772536480__en-us_topic_0000001706104857_en-us_topic_0000001383668660_en-us_topic_0214164778_p137241253124711">TEXT</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001772536480__en-us_topic_0000001706104857_en-us_topic_0000001383668660_en-us_topic_0214164778_row6724153204711"><td class="cellrowborder" valign="top" width="19.99199919991999%" headers="mcps1.3.2.2.2.4.1.1 "><p id="EN-US_TOPIC_0000001772536480__en-us_topic_0000001706104857_en-us_topic_0000001383668660_en-us_topic_0214164778_p37246532473">TEXT</p>
</td>
<td class="cellrowborder" valign="top" width="36.94369436943694%" headers="mcps1.3.2.2.2.4.1.2 "><p id="EN-US_TOPIC_0000001772536480__en-us_topic_0000001706104857_en-us_topic_0000001383668660_en-us_topic_0214164778_p7724125315478">TEXT</p>
</td>
<td class="cellrowborder" valign="top" width="43.064306430643065%" headers="mcps1.3.2.2.2.4.1.3 "><p id="EN-US_TOPIC_0000001772536480__en-us_topic_0000001706104857_en-us_topic_0000001383668660_en-us_topic_0214164778_p47241532472">TEXT</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001772536480__en-us_topic_0000001706104857_en-us_topic_0000001383668660_en-us_topic_0214164778_row1272475324711"><td class="cellrowborder" valign="top" width="19.99199919991999%" headers="mcps1.3.2.2.2.4.1.1 "><p id="EN-US_TOPIC_0000001772536480__en-us_topic_0000001706104857_en-us_topic_0000001383668660_en-us_topic_0214164778_p1872465318474">TINYTEXT</p>
</td>
<td class="cellrowborder" valign="top" width="36.94369436943694%" headers="mcps1.3.2.2.2.4.1.2 "><p id="EN-US_TOPIC_0000001772536480__en-us_topic_0000001706104857_en-us_topic_0000001383668660_en-us_topic_0214164778_p1172410531476">TINYTEXT</p>
</td>
<td class="cellrowborder" valign="top" width="43.064306430643065%" headers="mcps1.3.2.2.2.4.1.3 "><p id="EN-US_TOPIC_0000001772536480__en-us_topic_0000001706104857_en-us_topic_0000001383668660_en-us_topic_0214164778_p197245538472">TEXT</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001772536480__en-us_topic_0000001706104857_en-us_topic_0000001383668660_en-us_topic_0214164778_row4724205314719"><td class="cellrowborder" valign="top" width="19.99199919991999%" headers="mcps1.3.2.2.2.4.1.1 "><p id="EN-US_TOPIC_0000001772536480__en-us_topic_0000001706104857_en-us_topic_0000001383668660_en-us_topic_0214164778_p1072405316473">VARCHAR</p>
</td>
<td class="cellrowborder" valign="top" width="36.94369436943694%" headers="mcps1.3.2.2.2.4.1.2 "><p id="EN-US_TOPIC_0000001772536480__en-us_topic_0000001706104857_en-us_topic_0000001383668660_en-us_topic_0214164778_p27241553134720">VARCHAR[(0)]</p>
<p id="EN-US_TOPIC_0000001772536480__en-us_topic_0000001706104857_en-us_topic_0000001383668660_p10543163415432">VARCHAR[(n)]</p>
</td>
<td class="cellrowborder" valign="top" width="43.064306430643065%" headers="mcps1.3.2.2.2.4.1.3 "><p id="EN-US_TOPIC_0000001772536480__en-us_topic_0000001706104857_en-us_topic_0000001383668660_en-us_topic_0214164778_p3299187172314">VARCHAR[(1)]</p>
<p id="EN-US_TOPIC_0000001772536480__en-us_topic_0000001706104857_en-us_topic_0000001383668660_p538517214449">VARCHAR[(4n)]</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001772536480__en-us_topic_0000001706104857_en-us_topic_0000001383668660_row75451352105010"><td class="cellrowborder" valign="top" width="19.99199919991999%" headers="mcps1.3.2.2.2.4.1.1 "><p id="EN-US_TOPIC_0000001772536480__en-us_topic_0000001706104857_en-us_topic_0000001383668660_p195466524500">NVARCHAR</p>
</td>
<td class="cellrowborder" valign="top" width="36.94369436943694%" headers="mcps1.3.2.2.2.4.1.2 "><p id="EN-US_TOPIC_0000001772536480__en-us_topic_0000001706104857_en-us_topic_0000001383668660_p854712524501">NVARCHAR[(0)]</p>
<p id="EN-US_TOPIC_0000001772536480__en-us_topic_0000001706104857_en-us_topic_0000001383668660_p613510426381">NVARCHAR[(n)]</p>
</td>
<td class="cellrowborder" valign="top" width="43.064306430643065%" headers="mcps1.3.2.2.2.4.1.3 "><p id="EN-US_TOPIC_0000001772536480__en-us_topic_0000001706104857_en-us_topic_0000001383668660_p14547205275016">VARCHAR[(1)]</p>
<p id="EN-US_TOPIC_0000001772536480__en-us_topic_0000001706104857_en-us_topic_0000001383668660_p88183617395">VARCHAR[(4n)]</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001772536480__en-us_topic_0000001706104857_en-us_topic_0000001383668660_row13590223173413"><td class="cellrowborder" valign="top" width="19.99199919991999%" headers="mcps1.3.2.2.2.4.1.1 "><p id="EN-US_TOPIC_0000001772536480__en-us_topic_0000001706104857_en-us_topic_0000001383668660_p1859122316340">CHARACTE VARYING</p>
</td>
<td class="cellrowborder" valign="top" width="36.94369436943694%" headers="mcps1.3.2.2.2.4.1.2 "><p id="EN-US_TOPIC_0000001772536480__en-us_topic_0000001706104857_en-us_topic_0000001383668660_p7591132310347">CHARACTE VARYING</p>
</td>
<td class="cellrowborder" valign="top" width="43.064306430643065%" headers="mcps1.3.2.2.2.4.1.3 "><p id="EN-US_TOPIC_0000001772536480__en-us_topic_0000001706104857_en-us_topic_0000001383668660_p165926236343">VARCHAR</p>
</td>
</tr>
</tbody>
</table>
</div>
<div class="note" id="EN-US_TOPIC_0000001772536480__en-us_topic_0000001706104857_en-us_topic_0000001383668660_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_0000001772536480__en-us_topic_0000001706104857_en-us_topic_0000001383668660_ul275624143316"><li id="EN-US_TOPIC_0000001772536480__en-us_topic_0000001706104857_en-us_topic_0000001383668660_li27561841133310">During CHAR/CHARACTER/NCHAR conversion, if the precision is less than or equal to 0, it is converted to CHAR(1). If the precision is greater than 0, it is converted to a precision level four times that of the CHAR type.</li><li id="EN-US_TOPIC_0000001772536480__en-us_topic_0000001706104857_en-us_topic_0000001383668660_li275634110337">During VARCHAR/NVARCHAR conversion, if the precision is less than or equal to 0, it is converted to VARCHAR(1). If the precision is greater than 0, it is converted to a precision four times that of the VARCHAR type.</li></ul>
</div></div>
<p id="EN-US_TOPIC_0000001772536480__en-us_topic_0000001706104857_en-us_topic_0000001383668660_en-us_topic_0214164778_p1332213218563"><strong id="EN-US_TOPIC_0000001772536480__en-us_topic_0000001706104857_en-us_topic_0000001383668660_b184522217332237">Input: CHAR</strong></p>
<p id="EN-US_TOPIC_0000001772536480__en-us_topic_0000001706104857_en-us_topic_0000001383668660_en-us_topic_0214164778_p12944152105919">In MySQL, the length of a CHAR column is fixed to the length that you declare when you create the table. The length can be any value from 0 to 255. When CHAR values are stored, they are right-padded with spaces to the specified length.</p>
<pre class="screen" id="EN-US_TOPIC_0000001772536480__en-us_topic_0000001706104857_en-us_topic_0000001383668660_en-us_topic_0214164778_screen5757445165618">CREATE TABLE IF NOT EXISTS `runoob_dataType_test`(
`dataType_1` CHAR NOT NULL,
`dataType_2` CHAR(0) NOT NULL,
`dataType_3` CHAR(255) NOT NULL
);</pre>
<p id="EN-US_TOPIC_0000001772536480__en-us_topic_0000001706104857_en-us_topic_0000001383668660_en-us_topic_0214164778_p1450505613564"><strong id="EN-US_TOPIC_0000001772536480__en-us_topic_0000001706104857_en-us_topic_0000001383668660_en-us_topic_0214164778_b155141068575">Output</strong></p>
<pre class="screen" id="EN-US_TOPIC_0000001772536480__en-us_topic_0000001706104857_en-us_topic_0000001383668660_en-us_topic_0214164778_screen664112985711">CREATE TABLE IF NOT EXISTS "public"."runoob_datatype_test"
(
"datatype_1" CHAR NOT NULL,
"datatype_2" CHAR(1) NOT NULL,
"datatype_3" CHAR(1020) NOT NULL
)
WITH ( ORIENTATION = ROW, COMPRESSION = NO )
NOCOMPRESS
DISTRIBUTE BY HASH ("datatype_1");</pre>
<p id="EN-US_TOPIC_0000001772536480__en-us_topic_0000001706104857_en-us_topic_0000001383668660_en-us_topic_0214164778_p7451444139"><strong id="EN-US_TOPIC_0000001772536480__en-us_topic_0000001706104857_en-us_topic_0000001383668660_b73983912832237">Input: [LONG|MEDIUM|TINY]TEXT</strong></p>
<pre class="screen" id="EN-US_TOPIC_0000001772536480__en-us_topic_0000001706104857_en-us_topic_0000001383668660_en-us_topic_0214164778_screen65801418121312">CREATE TABLE IF NOT EXISTS `runoob_dataType_test`(
`dataType_1` LONGTEXT,
`dataType_2` MEDIUMTEXT,
`dataType_3` TEXT,
`dataType_4` TINYTEXT
);</pre>
<p id="EN-US_TOPIC_0000001772536480__en-us_topic_0000001706104857_en-us_topic_0000001383668660_en-us_topic_0214164778_p173603223130"><strong id="EN-US_TOPIC_0000001772536480__en-us_topic_0000001706104857_en-us_topic_0000001383668660_en-us_topic_0214164778_b3179193114132">Output</strong></p>
<pre class="screen" id="EN-US_TOPIC_0000001772536480__en-us_topic_0000001706104857_en-us_topic_0000001383668660_en-us_topic_0214164778_screen832373451312">CREATE TABLE IF NOT EXISTS "public"."runoob_datatype_test"
(
"datatype_1" TEXT,
"datatype_2" TEXT,
"datatype_3" TEXT,
"datatype_4" TEXT
)
WITH ( ORIENTATION = ROW, COMPRESSION = NO )
NOCOMPRESS
DISTRIBUTE BY HASH ("datatype_1");</pre>
<p id="EN-US_TOPIC_0000001772536480__en-us_topic_0000001706104857_en-us_topic_0000001383668660_en-us_topic_0214164778_p96511315182316"><strong id="EN-US_TOPIC_0000001772536480__en-us_topic_0000001706104857_en-us_topic_0000001383668660_b20033156632237">Input: VARCHAR</strong></p>
<p id="EN-US_TOPIC_0000001772536480__en-us_topic_0000001706104857_en-us_topic_0000001383668660_en-us_topic_0214164778_p753071482610">In MySQL, values in VARCHAR columns are variable-length strings. The length can be any value from 0 to 65,535.</p>
<pre class="screen" id="EN-US_TOPIC_0000001772536480__en-us_topic_0000001706104857_en-us_topic_0000001383668660_en-us_topic_0214164778_screen7921134313234">CREATE TABLE IF NOT EXISTS `runoob_dataType_test`(
`dataType_1` VARCHAR(0),
`dataType_2` VARCHAR(1845)
);</pre>
<p id="EN-US_TOPIC_0000001772536480__en-us_topic_0000001706104857_en-us_topic_0000001383668660_en-us_topic_0214164778_p66121142414"><strong id="EN-US_TOPIC_0000001772536480__en-us_topic_0000001706104857_en-us_topic_0000001383668660_en-us_topic_0214164778_b1529715133247">Output</strong></p>
<pre class="screen" id="EN-US_TOPIC_0000001772536480__en-us_topic_0000001706104857_en-us_topic_0000001383668660_en-us_topic_0214164778_screen1814519189245">CREATE TABLE IF NOT EXISTS "public"."runoob_datatype_test"
(
"datatype_1" VARCHAR(1),
"datatype_2" VARCHAR(7380)
)
WITH ( ORIENTATION = ROW, COMPRESSION = NO )
NOCOMPRESS
DISTRIBUTE BY HASH ("datatype_1");</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>