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

146 lines
13 KiB
HTML

<a name="EN-US_TOPIC_0000001772696156"></a><a name="EN-US_TOPIC_0000001772696156"></a>
<h1 class="topictitle1">Date/Time Types</h1>
<div id="body8662426"><div class="section" id="EN-US_TOPIC_0000001772696156__en-us_topic_0000001706105129_en-us_topic_0000001383509040_section1772031175011"><h4 class="sectiontitle">Overview</h4><p id="EN-US_TOPIC_0000001772696156__en-us_topic_0000001706105129_en-us_topic_0000001383509040_p1275161825019">This section describes the following date and time types: DATETIME, TIME, TIMESTAMP, and YEAR. GaussDB(DWS) does not support these types, and DSC will convert them.</p>
</div>
<div class="section" id="EN-US_TOPIC_0000001772696156__en-us_topic_0000001706105129_en-us_topic_0000001383509040_section169541924125013"><h4 class="sectiontitle">Type Mapping</h4>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="EN-US_TOPIC_0000001772696156__en-us_topic_0000001706105129_en-us_topic_0000001383509040_en-us_topic_0214164385_table10117648917" frame="border" border="1" rules="all"><caption><b>Table 1 </b>Date/Time type mapping</caption><thead align="left"><tr id="EN-US_TOPIC_0000001772696156__en-us_topic_0000001706105129_en-us_topic_0000001383509040_en-us_topic_0214164385_row211754814117"><th align="left" class="cellrowborder" valign="top" width="15.261526152615263%" id="mcps1.3.2.2.2.4.1.1"><p id="EN-US_TOPIC_0000001772696156__en-us_topic_0000001706105129_en-us_topic_0000001383509040_en-us_topic_0214164385_p1813718121298">MySQL Date/Time Type</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="41.94419441944194%" id="mcps1.3.2.2.2.4.1.2"><p id="EN-US_TOPIC_0000001772696156__en-us_topic_0000001706105129_en-us_topic_0000001383509040_en-us_topic_0214164385_p132812189918">MySQL INPUT</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="42.7942794279428%" id="mcps1.3.2.2.2.4.1.3"><p id="EN-US_TOPIC_0000001772696156__en-us_topic_0000001706105129_en-us_topic_0000001383509040_en-us_topic_0214164385_p990525598">GaussDB(DWS) OUTPUT</p>
</th>
</tr>
</thead>
<tbody><tr id="EN-US_TOPIC_0000001772696156__en-us_topic_0000001706105129_en-us_topic_0000001383509040_en-us_topic_0214164385_row191171848612"><td class="cellrowborder" valign="top" width="15.261526152615263%" headers="mcps1.3.2.2.2.4.1.1 "><p id="EN-US_TOPIC_0000001772696156__en-us_topic_0000001706105129_en-us_topic_0000001383509040_en-us_topic_0214164385_p2117144817114">DATETIME</p>
</td>
<td class="cellrowborder" valign="top" width="41.94419441944194%" headers="mcps1.3.2.2.2.4.1.2 "><p id="EN-US_TOPIC_0000001772696156__en-us_topic_0000001706105129_en-us_topic_0000001383509040_en-us_topic_0214164385_p17246154911118">DATETIME[(fsp)]</p>
</td>
<td class="cellrowborder" valign="top" width="42.7942794279428%" headers="mcps1.3.2.2.2.4.1.3 "><p id="EN-US_TOPIC_0000001772696156__en-us_topic_0000001706105129_en-us_topic_0000001383509040_en-us_topic_0214164385_p14117748117">TIMESTAMP[(fsp)] WITHOUT TIME ZONE</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001772696156__en-us_topic_0000001706105129_en-us_topic_0000001383509040_en-us_topic_0214164385_row811754814114"><td class="cellrowborder" valign="top" width="15.261526152615263%" headers="mcps1.3.2.2.2.4.1.1 "><p id="EN-US_TOPIC_0000001772696156__en-us_topic_0000001706105129_en-us_topic_0000001383509040_en-us_topic_0214164385_p1311716481914">TIME</p>
</td>
<td class="cellrowborder" valign="top" width="41.94419441944194%" headers="mcps1.3.2.2.2.4.1.2 "><p id="EN-US_TOPIC_0000001772696156__en-us_topic_0000001706105129_en-us_topic_0000001383509040_en-us_topic_0214164385_p17333112414198">TIME[(fsp)]</p>
</td>
<td class="cellrowborder" valign="top" width="42.7942794279428%" headers="mcps1.3.2.2.2.4.1.3 "><p id="EN-US_TOPIC_0000001772696156__en-us_topic_0000001706105129_en-us_topic_0000001383509040_en-us_topic_0214164385_p1048028132215">TIME[(fsp)] WITHOUT TIME ZONE</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001772696156__en-us_topic_0000001706105129_en-us_topic_0000001383509040_en-us_topic_0214164385_row849212317819"><td class="cellrowborder" valign="top" width="15.261526152615263%" headers="mcps1.3.2.2.2.4.1.1 "><p id="EN-US_TOPIC_0000001772696156__en-us_topic_0000001706105129_en-us_topic_0000001383509040_en-us_topic_0214164385_p101171948213">TIMESTAMP</p>
</td>
<td class="cellrowborder" valign="top" width="41.94419441944194%" headers="mcps1.3.2.2.2.4.1.2 "><p id="EN-US_TOPIC_0000001772696156__en-us_topic_0000001706105129_en-us_topic_0000001383509040_en-us_topic_0214164385_p0297138191114">TIMESTAMP[(fsp)]</p>
</td>
<td class="cellrowborder" valign="top" width="42.7942794279428%" headers="mcps1.3.2.2.2.4.1.3 "><p id="EN-US_TOPIC_0000001772696156__en-us_topic_0000001706105129_en-us_topic_0000001383509040_en-us_topic_0214164385_p2493231986">TIMESTAMP[(fsp)] WITH TIME ZONE</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001772696156__en-us_topic_0000001706105129_en-us_topic_0000001383509040_en-us_topic_0214164385_row121184481113"><td class="cellrowborder" valign="top" width="15.261526152615263%" headers="mcps1.3.2.2.2.4.1.1 "><p id="EN-US_TOPIC_0000001772696156__en-us_topic_0000001706105129_en-us_topic_0000001383509040_en-us_topic_0214164385_p181182480115">YEAR</p>
</td>
<td class="cellrowborder" valign="top" width="41.94419441944194%" headers="mcps1.3.2.2.2.4.1.2 "><p id="EN-US_TOPIC_0000001772696156__en-us_topic_0000001706105129_en-us_topic_0000001383509040_en-us_topic_0214164385_p415210743813">YEAR[(4)]</p>
</td>
<td class="cellrowborder" valign="top" width="42.7942794279428%" headers="mcps1.3.2.2.2.4.1.3 "><p id="EN-US_TOPIC_0000001772696156__en-us_topic_0000001706105129_en-us_topic_0000001383509040_en-us_topic_0214164385_p31181048018">SMALLINT(4)</p>
</td>
</tr>
</tbody>
</table>
</div>
<div class="note" id="EN-US_TOPIC_0000001772696156__en-us_topic_0000001706105129_en-us_topic_0000001383509040_en-us_topic_0214164385_note1544699172110"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="EN-US_TOPIC_0000001772696156__en-us_topic_0000001706105129_en-us_topic_0000001383509040_en-us_topic_0214164385_p144614942110">The value of <em id="EN-US_TOPIC_0000001772696156__en-us_topic_0000001706105129_en-us_topic_0000001383509040_en-us_topic_0214164385_i3510134512263">fsp</em> must be in the range [0, 6]. Value <strong id="EN-US_TOPIC_0000001772696156__en-us_topic_0000001706105129_en-us_topic_0000001383509040_b61772069432325">0</strong> indicates no decimal. If this parameter is omitted, the default precision will be 0.</p>
</div></div>
<p id="EN-US_TOPIC_0000001772696156__en-us_topic_0000001706105129_en-us_topic_0000001383509040_en-us_topic_0214164385_p816910530159"><strong id="EN-US_TOPIC_0000001772696156__en-us_topic_0000001706105129_en-us_topic_0000001383509040_b39270388632325">Input: DATETIME</strong></p>
<pre class="screen" id="EN-US_TOPIC_0000001772696156__en-us_topic_0000001706105129_en-us_topic_0000001383509040_en-us_topic_0214164385_screen14680186141612">CREATE TABLE IF NOT EXISTS `runoob_dataType_test`(
`dataType_1` DATETIME,
`dataType_2` DATETIME(0),
`dataType_3` DATETIME(6),
`dataType_4` DATETIME DEFAULT NULL,
`dataType_5` DATETIME DEFAULT '2018-10-12 15:27:33.999999'
);</pre>
<p id="EN-US_TOPIC_0000001772696156__en-us_topic_0000001706105129_en-us_topic_0000001383509040_en-us_topic_0214164385_p187956221168"><strong id="EN-US_TOPIC_0000001772696156__en-us_topic_0000001706105129_en-us_topic_0000001383509040_en-us_topic_0214164385_b9368193110165">Output</strong></p>
<pre class="screen" id="EN-US_TOPIC_0000001772696156__en-us_topic_0000001706105129_en-us_topic_0000001383509040_en-us_topic_0214164385_screen7538163431614">CREATE TABLE IF NOT EXISTS "public"."runoob_datatype_test"
(
"datatype_1" TIMESTAMP WITHOUT TIME ZONE,
"datatype_2" TIMESTAMP(0) WITHOUT TIME ZONE,
"datatype_3" TIMESTAMP(6) WITHOUT TIME ZONE,
"datatype_4" TIMESTAMP WITHOUT TIME ZONE DEFAULT NULL,
"datatype_5" TIMESTAMP WITHOUT TIME ZONE DEFAULT '2018-10-12 15:27:33.999999'
)
WITH ( ORIENTATION = ROW, COMPRESSION = NO )
NOCOMPRESS
DISTRIBUTE BY HASH ("datatype_1");</pre>
<p id="EN-US_TOPIC_0000001772696156__en-us_topic_0000001706105129_en-us_topic_0000001383509040_en-us_topic_0214164385_p1471211198174"><strong id="EN-US_TOPIC_0000001772696156__en-us_topic_0000001706105129_en-us_topic_0000001383509040_b88054984232325">Input: TIME</strong></p>
<pre class="screen" id="EN-US_TOPIC_0000001772696156__en-us_topic_0000001706105129_en-us_topic_0000001383509040_en-us_topic_0214164385_screen141821659172213">CREATE TABLE IF NOT EXISTS `runoob_dataType_test`(
`dataType_1` TIME DEFAULT '20:58:10',
`dataType_2` TIME(3) DEFAULT '20:58:10',
`dataType_3` TIME(6) DEFAULT '20:58:10',
`dataType_4` TIME(6) DEFAULT '2018-10-11 20:00:00',
`dataType_5` TIME(6) DEFAULT '20:58:10.01234',
`dataType_6` TIME(6) DEFAULT '2018-10-11 20:00:00.01234',
`dataType_7` TIME DEFAULT NULL,
`dataType_8` TIME(6) DEFAULT NULL,
PRIMARY KEY (dataType_1)
);</pre>
<p id="EN-US_TOPIC_0000001772696156__en-us_topic_0000001706105129_en-us_topic_0000001383509040_en-us_topic_0214164385_p342311319232"><strong id="EN-US_TOPIC_0000001772696156__en-us_topic_0000001706105129_en-us_topic_0000001383509040_en-us_topic_0214164385_b4466152217232">Output</strong></p>
<pre class="screen" id="EN-US_TOPIC_0000001772696156__en-us_topic_0000001706105129_en-us_topic_0000001383509040_en-us_topic_0214164385_screen6668112115232">CREATE TABLE IF NOT EXISTS "public"."runoob_datatype_test"
(
"datatype_1" TIME WITHOUT TIME ZONE DEFAULT '20:58:10',
"datatype_2" TIME(3) WITHOUT TIME ZONE DEFAULT '20:58:10',
"datatype_3" TIME(6) WITHOUT TIME ZONE DEFAULT '20:58:10',
"datatype_4" TIME(6) WITHOUT TIME ZONE DEFAULT '2018-10-11 20:00:00',
"datatype_5" TIME(6) WITHOUT TIME ZONE DEFAULT '20:58:10.01234',
"datatype_6" TIME(6) WITHOUT TIME ZONE DEFAULT '2018-10-11 20:00:00.01234',
"datatype_7" TIME WITHOUT TIME ZONE DEFAULT NULL,
"datatype_8" TIME(6) WITHOUT TIME ZONE DEFAULT NULL,
PRIMARY KEY ("datatype_1")
)
WITH ( ORIENTATION = ROW, COMPRESSION = NO )
NOCOMPRESS
DISTRIBUTE BY HASH ("datatype_1");</pre>
<p id="EN-US_TOPIC_0000001772696156__en-us_topic_0000001706105129_en-us_topic_0000001383509040_en-us_topic_0214164385_p173051253132315"><strong id="EN-US_TOPIC_0000001772696156__en-us_topic_0000001706105129_en-us_topic_0000001383509040_b165804149432325">Input: TIMESTAMP</strong></p>
<pre class="screen" id="EN-US_TOPIC_0000001772696156__en-us_topic_0000001706105129_en-us_topic_0000001383509040_en-us_topic_0214164385_screen1540911813244">CREATE TABLE IF NOT EXISTS `runoob_dataType_test`(
`dataType_1` TIMESTAMP,
`dateType_4` TIMESTAMP DEFAULT '2018-10-12 15:27:33',
`dateType_5` TIMESTAMP DEFAULT '2018-10-12 15:27:33.999999',
`dateType_6` TIMESTAMP DEFAULT '2018-10-12 15:27:33',
`dateType_7` TIMESTAMP DEFAULT '2018-10-12 15:27:33',
`dataType_8` TIMESTAMP(0) DEFAULT '2018-10-12 15:27:33',
`dateType_9` TIMESTAMP(6) DEFAULT '2018-10-12 15:27:33'
);</pre>
<p id="EN-US_TOPIC_0000001772696156__en-us_topic_0000001706105129_en-us_topic_0000001383509040_en-us_topic_0214164385_p1842112313362"><strong id="EN-US_TOPIC_0000001772696156__en-us_topic_0000001706105129_en-us_topic_0000001383509040_en-us_topic_0214164385_b2173153143610">Output</strong></p>
<pre class="screen" id="EN-US_TOPIC_0000001772696156__en-us_topic_0000001706105129_en-us_topic_0000001383509040_en-us_topic_0214164385_screen126483333364">CREATE TABLE IF NOT EXISTS "public"."runoob_datatype_test"
(
"datatype_1" TIMESTAMP WITH TIME ZONE,
"datetype_4" TIMESTAMP WITH TIME ZONE DEFAULT '2018-10-12 15:27:33',
"datetype_5" TIMESTAMP WITH TIME ZONE DEFAULT '2018-10-12 15:27:33.999999',
"datetype_6" TIMESTAMP WITH TIME ZONE DEFAULT '2018-10-12 15:27:33',
"datetype_7" TIMESTAMP WITH TIME ZONE DEFAULT '2018-10-12 15:27:33',
"datatype_8" TIMESTAMP(0) WITH TIME ZONE DEFAULT '2018-10-12 15:27:33',
"datetype_9" TIMESTAMP(6) WITH TIME ZONE DEFAULT '2018-10-12 15:27:33'
)
WITH ( ORIENTATION = ROW, COMPRESSION = NO )
NOCOMPRESS
DISTRIBUTE BY HASH ("datatype_1");</pre>
<p id="EN-US_TOPIC_0000001772696156__en-us_topic_0000001706105129_en-us_topic_0000001383509040_en-us_topic_0214164385_p4692849164111"><strong id="EN-US_TOPIC_0000001772696156__en-us_topic_0000001706105129_en-us_topic_0000001383509040_b68893011132325">Input: YEAR</strong></p>
<pre class="screen" id="EN-US_TOPIC_0000001772696156__en-us_topic_0000001706105129_en-us_topic_0000001383509040_en-us_topic_0214164385_screen18889171234212">CREATE TABLE IF NOT EXISTS `runoob_dataType_test`(
`dataType_1` YEAR,
`dataType_2` YEAR(4),
`dataType_3` YEAR DEFAULT '2018',
`dataType_4` TIME DEFAULT NULL
);</pre>
<p id="EN-US_TOPIC_0000001772696156__en-us_topic_0000001706105129_en-us_topic_0000001383509040_en-us_topic_0214164385_p17991163914424"><strong id="EN-US_TOPIC_0000001772696156__en-us_topic_0000001706105129_en-us_topic_0000001383509040_en-us_topic_0214164385_b15206174817423">Output</strong></p>
<pre class="screen" id="EN-US_TOPIC_0000001772696156__en-us_topic_0000001706105129_en-us_topic_0000001383509040_en-us_topic_0214164385_screen1997195164217">CREATE TABLE IF NOT EXISTS "public"."runoob_datatype_test"
(
"datatype_1" SMALLINT,
"datatype_2" SMALLINT,
"datatype_3" VARCHAR(4) DEFAULT '2018',
"datatype_4" TIME WITHOUT TIME ZONE DEFAULT NULL
)
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>