forked from docs/doc-exports
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>
92 lines
9.0 KiB
HTML
92 lines
9.0 KiB
HTML
<a name="EN-US_TOPIC_0000001819416197"></a><a name="EN-US_TOPIC_0000001819416197"></a>
|
|
|
|
<h1 class="topictitle1">Binary Types</h1>
|
|
<div id="body8662426"><div class="section" id="EN-US_TOPIC_0000001819416197__en-us_topic_0000001706105057_en-us_topic_0000001433828421_section13891170102716"><h4 class="sectiontitle">Overview</h4><ul id="EN-US_TOPIC_0000001819416197__en-us_topic_0000001706105057_en-us_topic_0000001433828421_en-us_topic_0214164579_ul20144128162512"><li id="EN-US_TOPIC_0000001819416197__en-us_topic_0000001706105057_en-us_topic_0000001433828421_en-us_topic_0214164579_li31449812517">In MySQL, the BIT data type is used to store bit values. A type of BIT(<em id="EN-US_TOPIC_0000001819416197__en-us_topic_0000001706105057_en-us_topic_0000001433828421_i18277134573213">M</em>) enables storage of <em id="EN-US_TOPIC_0000001819416197__en-us_topic_0000001706105057_en-us_topic_0000001433828421_i482670183213">M</em>-bit values. <em id="EN-US_TOPIC_0000001819416197__en-us_topic_0000001706105057_en-us_topic_0000001433828421_i16527949933213">M</em> can range from 1 to 64.</li><li id="EN-US_TOPIC_0000001819416197__en-us_topic_0000001706105057_en-us_topic_0000001433828421_en-us_topic_0214164579_li275535610267">MySQL BINARY and VARBINARY types are similar to CHAR and VARCHAR, except that they contain binary strings rather than non-binary strings.</li></ul>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001819416197__en-us_topic_0000001706105057_en-us_topic_0000001433828421_section115051213142716"><h4 class="sectiontitle">Type Mapping</h4>
|
|
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="EN-US_TOPIC_0000001819416197__en-us_topic_0000001706105057_en-us_topic_0000001433828421_en-us_topic_0214164624_table8357194922719" frame="border" border="1" rules="all"><caption><b>Table 1 </b>Binary type mapping</caption><thead align="left"><tr id="EN-US_TOPIC_0000001819416197__en-us_topic_0000001706105057_en-us_topic_0000001433828421_en-us_topic_0214164624_row203574498277"><th align="left" class="cellrowborder" valign="top" width="33.33333333333333%" id="mcps1.3.2.2.2.4.1.1"><p id="EN-US_TOPIC_0000001819416197__en-us_topic_0000001706105057_en-us_topic_0000001433828421_en-us_topic_0214164624_p11357049102713">MySQL Binary 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_0000001819416197__en-us_topic_0000001706105057_en-us_topic_0000001433828421_en-us_topic_0214164624_p1835718492278">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_0000001819416197__en-us_topic_0000001706105057_en-us_topic_0000001433828421_en-us_topic_0214164624_p535794918273">GaussDB(DWS) OUTPUT</p>
|
|
</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody><tr id="EN-US_TOPIC_0000001819416197__en-us_topic_0000001706105057_en-us_topic_0000001433828421_en-us_topic_0214164624_row5357104942717"><td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.3.2.2.2.4.1.1 "><p id="EN-US_TOPIC_0000001819416197__en-us_topic_0000001706105057_en-us_topic_0000001433828421_en-us_topic_0214164624_p635754962710">BIT[(M)]</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.3.2.2.2.4.1.2 "><p id="EN-US_TOPIC_0000001819416197__en-us_topic_0000001706105057_en-us_topic_0000001433828421_en-us_topic_0214164624_p9357104962712">BIT[(M)]</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.3.2.2.2.4.1.3 "><p id="EN-US_TOPIC_0000001819416197__en-us_topic_0000001706105057_en-us_topic_0000001433828421_en-us_topic_0214164624_p035754932711">BIT[(M)]</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="EN-US_TOPIC_0000001819416197__en-us_topic_0000001706105057_en-us_topic_0000001433828421_en-us_topic_0214164624_row173575497272"><td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.3.2.2.2.4.1.1 "><p id="EN-US_TOPIC_0000001819416197__en-us_topic_0000001706105057_en-us_topic_0000001433828421_en-us_topic_0214164624_p53589496271">BINARY[(M)]</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.3.2.2.2.4.1.2 "><p id="EN-US_TOPIC_0000001819416197__en-us_topic_0000001706105057_en-us_topic_0000001433828421_en-us_topic_0214164624_p135811498275">BINARY[(M)]</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.3.2.2.2.4.1.3 "><p id="EN-US_TOPIC_0000001819416197__en-us_topic_0000001706105057_en-us_topic_0000001433828421_en-us_topic_0214164624_p1335884913278">BYTEA</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="EN-US_TOPIC_0000001819416197__en-us_topic_0000001706105057_en-us_topic_0000001433828421_row2052122615442"><td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.3.2.2.2.4.1.1 "><p id="EN-US_TOPIC_0000001819416197__en-us_topic_0000001706105057_en-us_topic_0000001433828421_p155392615449">CHAR BYTE[(M)]</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.3.2.2.2.4.1.2 "><p id="EN-US_TOPIC_0000001819416197__en-us_topic_0000001706105057_en-us_topic_0000001433828421_p1453162654420">BINARY[(M)]</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.3.2.2.2.4.1.3 "><p id="EN-US_TOPIC_0000001819416197__en-us_topic_0000001706105057_en-us_topic_0000001433828421_p1753426144415">BYTEA</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="EN-US_TOPIC_0000001819416197__en-us_topic_0000001706105057_en-us_topic_0000001433828421_en-us_topic_0214164624_row14358349102720"><td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.3.2.2.2.4.1.1 "><p id="EN-US_TOPIC_0000001819416197__en-us_topic_0000001706105057_en-us_topic_0000001433828421_en-us_topic_0214164624_p9358134902713">VARBINARY[(M)]</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.3.2.2.2.4.1.2 "><p id="EN-US_TOPIC_0000001819416197__en-us_topic_0000001706105057_en-us_topic_0000001433828421_en-us_topic_0214164624_p435811497274">VARBINARY[(M)]</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.3.2.2.2.4.1.3 "><p id="EN-US_TOPIC_0000001819416197__en-us_topic_0000001706105057_en-us_topic_0000001433828421_en-us_topic_0214164624_p14358049172711">BYTEA</p>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<p id="EN-US_TOPIC_0000001819416197__en-us_topic_0000001706105057_en-us_topic_0000001433828421_en-us_topic_0214164624_p98581946183019"><strong id="EN-US_TOPIC_0000001819416197__en-us_topic_0000001706105057_en-us_topic_0000001433828421_b6767443303213">Input: BIT</strong></p>
|
|
<pre class="screen" id="EN-US_TOPIC_0000001819416197__en-us_topic_0000001706105057_en-us_topic_0000001433828421_en-us_topic_0214164624_screen38077112319">CREATE TABLE IF NOT EXISTS `runoob_dataType_test`(
|
|
`dataType_1` INT,
|
|
`dataType_2` BIT(1),
|
|
`dataType_3` BIT(64)
|
|
);</pre>
|
|
<p id="EN-US_TOPIC_0000001819416197__en-us_topic_0000001706105057_en-us_topic_0000001433828421_en-us_topic_0214164624_p15847111219315"><strong id="EN-US_TOPIC_0000001819416197__en-us_topic_0000001706105057_en-us_topic_0000001433828421_en-us_topic_0214164624_b43211321123111">Output</strong></p>
|
|
<pre class="screen" id="EN-US_TOPIC_0000001819416197__en-us_topic_0000001706105057_en-us_topic_0000001433828421_en-us_topic_0214164624_screen1040352415318">CREATE TABLE IF NOT EXISTS "public"."runoob_datatype_test"
|
|
(
|
|
"datatype_1" INTEGER,
|
|
"datatype_2" BIT(1),
|
|
"datatype_3" BIT(64)
|
|
)
|
|
WITH ( ORIENTATION = ROW, COMPRESSION = NO )
|
|
NOCOMPRESS
|
|
DISTRIBUTE BY HASH ("datatype_1");</pre>
|
|
<p id="EN-US_TOPIC_0000001819416197__en-us_topic_0000001706105057_en-us_topic_0000001433828421_en-us_topic_0214164624_p04417351357"><strong id="EN-US_TOPIC_0000001819416197__en-us_topic_0000001706105057_en-us_topic_0000001433828421_b577556743213">Input: [VAR]BINARY</strong></p>
|
|
<pre class="screen" id="EN-US_TOPIC_0000001819416197__en-us_topic_0000001706105057_en-us_topic_0000001433828421_en-us_topic_0214164624_screen2261112533610">CREATE TABLE IF NOT EXISTS `runoob_dataType_test`(
|
|
`dataType_1` INT,
|
|
`dataType_2` BINARY,
|
|
`dataType_3` BINARY(0),
|
|
`dataType_4` BINARY(255),
|
|
`dataType_5` VARBINARY(0),
|
|
`dataType_6` VARBINARY(6553)
|
|
);</pre>
|
|
<p id="EN-US_TOPIC_0000001819416197__en-us_topic_0000001706105057_en-us_topic_0000001433828421_en-us_topic_0214164624_p5150184531611"><strong id="EN-US_TOPIC_0000001819416197__en-us_topic_0000001706105057_en-us_topic_0000001433828421_en-us_topic_0214164624_b118735910165">Output</strong></p>
|
|
<pre class="screen" id="EN-US_TOPIC_0000001819416197__en-us_topic_0000001706105057_en-us_topic_0000001433828421_en-us_topic_0214164624_screen152741325177">CREATE TABLE IF NOT EXISTS "public"."runoob_datatype_test"
|
|
(
|
|
"datatype_1" INTEGER,
|
|
"datatype_2" BYTEA,
|
|
"datatype_3" BYTEA,
|
|
"datatype_4" BYTEA,
|
|
"datatype_5" BYTEA,
|
|
"datatype_6" BYTEA
|
|
)
|
|
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>
|
|
|