1
0
forked from docs/doc-exports
doc-exports/docs/dws/tool/dws_16_0117.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

211 lines
29 KiB
HTML

<a name="EN-US_TOPIC_0000001772696164"></a><a name="EN-US_TOPIC_0000001772696164"></a>
<h1 class="topictitle1">Functions and Expressions</h1>
<div id="body8662426"><div class="section" id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_section1880684002714"><h4 class="sectiontitle">Overview</h4><p id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_p8304453883">The functions and expressions in MySQL do not exist in GaussDB(DWS) or are different from those in GaussDB(DWS). DSC migrates the functions and expressions based on the supported types of GaussDB(DWS). (compatible with ADB for MySQL)</p>
</div>
<div class="section" id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_section16664135316273"><h4 class="sectiontitle">Type Mapping</h4>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_table5353144454216" frame="border" border="1" rules="all"><caption><b>Table 1 </b>Type mapping</caption><thead align="left"><tr id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_row10354144114211"><th align="left" class="cellrowborder" valign="top" width="16.44835516448355%" id="mcps1.3.2.2.2.5.1.1"><p id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_p17354144424211">MySQL/ADB Function</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="21.897810218978105%" id="mcps1.3.2.2.2.5.1.2"><p id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_p646817252483">Description</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="30.796920307969206%" id="mcps1.3.2.2.2.5.1.3"><p id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_p133541444104216">MySQL INPUT</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="30.856914308569145%" id="mcps1.3.2.2.2.5.1.4"><p id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_p1035413446421">GaussDB(DWS) OUTPUT</p>
</th>
</tr>
</thead>
<tbody><tr id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_row103541044184216"><td class="cellrowborder" valign="top" width="16.44835516448355%" headers="mcps1.3.2.2.2.5.1.1 "><ul id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_ul243515488525"><li id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_li143519489528">CONVERT</li></ul>
</td>
<td class="cellrowborder" valign="top" width="21.897810218978105%" headers="mcps1.3.2.2.2.5.1.2 "><p id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_p34692252486">Converts a value to a specified data type or character set.</p>
</td>
<td class="cellrowborder" valign="top" width="30.796920307969206%" headers="mcps1.3.2.2.2.5.1.3 "><p id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_p6145194914163">CONVERT(A, B)</p>
</td>
<td class="cellrowborder" valign="top" width="30.856914308569145%" headers="mcps1.3.2.2.2.5.1.4 "><p id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_p1116065891615">CAST(A AS B)</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_row8392216123512"><td class="cellrowborder" valign="top" width="16.44835516448355%" headers="mcps1.3.2.2.2.5.1.1 "><ul id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_ul512018216531"><li id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_li6120142155311">CURDATE</li></ul>
</td>
<td class="cellrowborder" valign="top" width="21.897810218978105%" headers="mcps1.3.2.2.2.5.1.2 "><p id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_p148291124203518">Specifies the current date. It is synonymous with CURDATE().</p>
</td>
<td class="cellrowborder" valign="top" width="30.796920307969206%" headers="mcps1.3.2.2.2.5.1.3 "><p id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_p58291824113515">CURDATE/CURDATE()</p>
</td>
<td class="cellrowborder" valign="top" width="30.856914308569145%" headers="mcps1.3.2.2.2.5.1.4 "><p id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_p10829224203517">CURRENT_DATE ()</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_row137372517361"><td class="cellrowborder" valign="top" width="16.44835516448355%" headers="mcps1.3.2.2.2.5.1.1 "><ul id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_ul29781076535"><li id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_li9978107185314">GET_JSON_OBJECT</li></ul>
</td>
<td class="cellrowborder" valign="top" width="21.897810218978105%" headers="mcps1.3.2.2.2.5.1.2 "><p id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_p1316183283614">Parses a field in a JSON string.</p>
</td>
<td class="cellrowborder" valign="top" width="30.796920307969206%" headers="mcps1.3.2.2.2.5.1.3 "><p id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_p11614329368">GET_JSON_OBJECT(column, '$.obj.arg')</p>
<p id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_p716832193615">GET_JSON_OBJECT(column, '$[i]')</p>
</td>
<td class="cellrowborder" valign="top" width="30.856914308569145%" headers="mcps1.3.2.2.2.5.1.4 "><p id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_p121613293618">JSON_EXTRACT(column, 'obj', 'arg')</p>
<p id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_p1716163212364">JSON_ARRAY_ELEMENT(column, 0)</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_row136837366363"><td class="cellrowborder" valign="top" width="16.44835516448355%" headers="mcps1.3.2.2.2.5.1.1 "><ul id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_ul1415710135531"><li id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_li18157513155318">JSON_EXTRACT</li></ul>
</td>
<td class="cellrowborder" valign="top" width="21.897810218978105%" headers="mcps1.3.2.2.2.5.1.2 "><p id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_p098417437367">Queries the value of a field in JSON.</p>
</td>
<td class="cellrowborder" valign="top" width="30.796920307969206%" headers="mcps1.3.2.2.2.5.1.3 "><p id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_p298417430363">JSON_EXTRACT(column, '$.obj')</p>
</td>
<td class="cellrowborder" valign="top" width="30.856914308569145%" headers="mcps1.3.2.2.2.5.1.4 "><p id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_p89842437364">JSON_EXTRACT(column, 'obj')</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_row935415443424"><td class="cellrowborder" valign="top" width="16.44835516448355%" headers="mcps1.3.2.2.2.5.1.1 "><ul id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_ul7242141945317"><li id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_li1724281917539">REGEXP</li></ul>
</td>
<td class="cellrowborder" valign="top" width="21.897810218978105%" headers="mcps1.3.2.2.2.5.1.2 "><p id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_p546922516485">Fuzzy match</p>
</td>
<td class="cellrowborder" valign="top" width="30.796920307969206%" headers="mcps1.3.2.2.2.5.1.3 "><p id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_p343012652215">REGEXP A</p>
<p id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_p626815448235">NOT REGEXP A</p>
</td>
<td class="cellrowborder" valign="top" width="30.856914308569145%" headers="mcps1.3.2.2.2.5.1.4 "><p id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_p985595216237">~ A</p>
<p id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_p1078321072418">!~ A</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_row1033614129120"><td class="cellrowborder" valign="top" width="16.44835516448355%" headers="mcps1.3.2.2.2.5.1.1 "><ul id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_ul91481425195317"><li id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_li13149112595319">UUID</li></ul>
</td>
<td class="cellrowborder" valign="top" width="21.897810218978105%" headers="mcps1.3.2.2.2.5.1.2 "><p id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_p83377125124">Generates a unique value (sequence number).</p>
</td>
<td class="cellrowborder" valign="top" width="30.796920307969206%" headers="mcps1.3.2.2.2.5.1.3 "><p id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_p53371712101214">UUID</p>
</td>
<td class="cellrowborder" valign="top" width="30.856914308569145%" headers="mcps1.3.2.2.2.5.1.4 "><p id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_p233731216122">SYS_GUID</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_row8200106111212"><td class="cellrowborder" valign="top" width="16.44835516448355%" headers="mcps1.3.2.2.2.5.1.1 "><ul id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_ul207001829105314"><li id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_li167001829165319">SPLIT()[]</li></ul>
</td>
<td class="cellrowborder" valign="top" width="21.897810218978105%" headers="mcps1.3.2.2.2.5.1.2 "><p id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_p111662211123">Splits <strong id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_b15492805831630">string</strong> on <strong id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_b84593431630">delimiter</strong> and returns the <strong id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_b99079863731630">field</strong>th column (counting from text of the first appeared delimiter).</p>
</td>
<td class="cellrowborder" valign="top" width="30.796920307969206%" headers="mcps1.3.2.2.2.5.1.3 "><p id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_p1589075715120">SPLIT(string text, delimiter text)[field int]</p>
</td>
<td class="cellrowborder" valign="top" width="30.856914308569145%" headers="mcps1.3.2.2.2.5.1.4 "><p id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_p12202169125">SPLIT_PART(string text, delimiter text,field int)</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_row1741630191210"><td class="cellrowborder" valign="top" width="16.44835516448355%" headers="mcps1.3.2.2.2.5.1.1 "><ul id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_ul1154333316531"><li id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_li145441333105314">RAND</li></ul>
</td>
<td class="cellrowborder" valign="top" width="21.897810218978105%" headers="mcps1.3.2.2.2.5.1.2 "><p id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_p125465481715">Obtains a random number ranging from 0.0 to 1.0.</p>
</td>
<td class="cellrowborder" valign="top" width="30.796920307969206%" headers="mcps1.3.2.2.2.5.1.3 "><p id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_p1041713081215">RAND()</p>
</td>
<td class="cellrowborder" valign="top" width="30.856914308569145%" headers="mcps1.3.2.2.2.5.1.4 "><p id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_p8417605121">RANDOM()</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_row1041025421116"><td class="cellrowborder" valign="top" width="16.44835516448355%" headers="mcps1.3.2.2.2.5.1.1 "><ul id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_ul17964203711532"><li id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_li129641037195318">SLICE</li></ul>
</td>
<td class="cellrowborder" valign="top" width="21.897810218978105%" headers="mcps1.3.2.2.2.5.1.2 "><p id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_p1141116545113">Character string splitting. The first argument is the separator for the rest of the arguments.</p>
</td>
<td class="cellrowborder" valign="top" width="30.796920307969206%" headers="mcps1.3.2.2.2.5.1.3 "><p id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_p1141185491115">SLICE()</p>
</td>
<td class="cellrowborder" valign="top" width="30.856914308569145%" headers="mcps1.3.2.2.2.5.1.4 "><p id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_p94111654141119">CONCAT_WS(sep text, str"any" [, str"any" [, ...] ])</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_row911120201811"><td class="cellrowborder" valign="top" width="16.44835516448355%" headers="mcps1.3.2.2.2.5.1.1 "><ul id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_ul1956034215532"><li id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_li1356034235314">TRY_CAST</li></ul>
</td>
<td class="cellrowborder" valign="top" width="21.897810218978105%" headers="mcps1.3.2.2.2.5.1.2 "><p id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_p81121401186">Converts <strong id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_b54183747731630">x</strong> into the type specified by <strong id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_b137514371331630">y</strong>.</p>
</td>
<td class="cellrowborder" valign="top" width="30.796920307969206%" headers="mcps1.3.2.2.2.5.1.3 "><p id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_p31129071812">TRY_CAST(X AS Y)</p>
</td>
<td class="cellrowborder" valign="top" width="30.856914308569145%" headers="mcps1.3.2.2.2.5.1.4 "><p id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_p1811230101818">CAST(X AS Y)</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_row161381545141116"><td class="cellrowborder" valign="top" width="16.44835516448355%" headers="mcps1.3.2.2.2.5.1.1 "><ul id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_ul846874795319"><li id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_li346813474534">CAST</li></ul>
</td>
<td class="cellrowborder" valign="top" width="21.897810218978105%" headers="mcps1.3.2.2.2.5.1.2 "><p id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_p14139164514119">Converts <strong id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_b190148470231630">x</strong> into the type specified by <strong id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_b76627979131630">y</strong>.</p>
<p id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_p18898135883612">The second argument of the cast function in the ADB can be forcibly converted to the string or double-precision data type. In GaussDB(DWS), it is converted to the varchar or double precision type.</p>
</td>
<td class="cellrowborder" valign="top" width="30.796920307969206%" headers="mcps1.3.2.2.2.5.1.3 "><p id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_p3139114518117">CAST(X AS Y)</p>
</td>
<td class="cellrowborder" valign="top" width="30.856914308569145%" headers="mcps1.3.2.2.2.5.1.4 "><p id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_p16139124519119">CAST(X AS Y)</p>
</td>
</tr>
</tbody>
</table>
</div>
<p id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_p9404753123616"><strong id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_b34051253193615">Input example: CONVERT</strong></p>
<pre class="screen" id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_screen1140555311369">SELECT CONVERT (IFNULL (BUSINESS_ID, 0) , DECIMAL(18, 2)) FROM ACCOUNT;</pre>
<p id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_p5405195317367"><strong id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_b1405175383614">Output</strong></p>
<pre class="screen" id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_screen1440565310361">SELECT cast (ifnull (business_id, 0) AS decimal(18, 2))FROM account;</pre>
<p id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_p1032085803910"></p>
<p id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_p1198812519376"><strong id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_b11988152553719">Input example: CURDATE</strong></p>
<pre class="screen" id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_screen19885251377">SELECT CURDATE;
SELECT CURDATE();</pre>
<p id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_p0988925133716"><strong id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_b1598862523714">Output</strong></p>
<pre class="screen" id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_screen4988112573717">SELECT CURRENT_DATE();
SELECT CURRENT_DATE();</pre>
<p id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_p1623012343912"></p>
<p id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_p1623015393916"><strong id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_b10310183913105">Input example:</strong> <strong id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_b923018318391">GET_JSON_OBJECT</strong></p>
<pre class="screen" id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_screen6230034391">SELECT GET_JSON_OBJECT(COL_JSON, '$.STORE.BICYCLE.PRICE');
SELECT GET_JSON_OBJECT(COL_JSON, '$.STORE.FRUIT[0]');</pre>
<p id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_p14230163173914"><strong id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_b82309314393">Output</strong></p>
<pre class="screen" id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_screen1923053133917">SELECT
JSON_EXTRACT_PATH(COL_JSON, 'STORE', 'BICYCLE', 'PRICE');
SELECT
JSON_ARRAY_ELEMENT(JSON_EXTRACT_PATH(COL_JSON, 'STORE', 'FRUIT'), 0);</pre>
<p id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_p19972182253919"></p>
<p id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_p18972142219393"><strong id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_b5972182243915">Input example: JSON_EXTRACT</strong></p>
<pre class="screen" id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_screen997213221391">SELECT JSON_EXTRACT(EVENT_ATTR,'$.TOPIC_ID');</pre>
<p id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_p129729226391"><strong id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_b4972162283914">Output</strong></p>
<pre class="screen" id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_screen7973132293916">SELECT JSON_EXTRACT_PATH(EVENT_ATTR, 'TOPIC_ID');</pre>
<p id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_p8120422193918"></p>
<p id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_p756614811365"><strong id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_b1356613489364">Input example: REGEXP</strong></p>
<pre class="screen" id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_screen256624863616">SELECT * FROM USERS WHERE NAME NOT REGEXP '^ Wang';
SELECT * FROM USERS WHERE TEL REGEXP '[^4-5]{11}';</pre>
<p id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_p1356614853615"><strong id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_b6566164815361">Output</strong></p>
<pre class="screen" id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_screen1056664816366">SELECT * FROM USERS WHERE NAME !~ '^ Wang';
SELECT * FROM USERS WHERE TEL ~ '[^4-5]{11}';</pre>
<p id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_p1162412396018"><strong id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_b1062520398017">Input example: UUID</strong></p>
<pre class="screen" id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_screen10625203917019">SELECT CURDATE(str1), UUID(str2, str3) FROM T1;
SELECT A FROM B WHERE uuid() &gt; 2;</pre>
<p id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_p156254391206"><strong id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_b462523919015">Output</strong></p>
<pre class="screen" id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_screen062517391500">SELECT current_date (str1),sys_guid (str2, str3) FROM T1;
SELECT A FROM B WHERE sys_guid () &gt; 2;</pre>
<p id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_p710403420016"></p>
<p id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_p57138561726"><strong id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_b771317561124">Input example: SPLIT()[]</strong></p>
<pre class="screen" id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_screen3714656726">SELECT split('a-b-c-d-e', '-')[4];</pre>
<p id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_p771416564214"><strong id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_b2071412560210">Output</strong></p>
<pre class="screen" id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_screen071417561224">SELECT split_part('a-b-c-d-e', '-', 4);</pre>
<p id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_p913012549214"></p>
<p id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_p167741378319"><strong id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_b6774674312">Input Example RAND</strong></p>
<pre class="screen" id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_screen5774875312">SELECT rand();</pre>
<p id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_p15774147438"><strong id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_b18774279318">Output</strong></p>
<pre class="screen" id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_screen19774187434">SELECT random ();</pre>
<p id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_p17371165432"></p>
<p id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_p1958441033410"><strong id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_b20584171013411">Input Example: SLICE</strong></p>
<pre class="screen" id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_screen12584610153415">SELECT slice(split('2021_08_01','_'),1,3) from dual;</pre>
<p id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_p158421015347"><strong id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_b7584131014347">Output</strong></p>
<pre class="screen" id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_screen7584131014345">SELECT
concat_ws(
split_part('2021_08_01', '_', 1),
split_part('2021_08_01', '_', 2),
split_part('2021_08_01', '_', 3)
)
FROM
dual;</pre>
<p id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_p67561274345"></p>
<p id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_p199551613364"><strong id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_b195512193618">Input example: TRY_CAST</strong></p>
<pre class="screen" id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_screen395511111364">select * from ods_pub where try_cast(pay_time AS timestamp) &gt;= 1;
select try_cast(pay_time as timestamp) from obs_pub;</pre>
<p id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_p39551016365"><strong id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_b895651153611">Output</strong></p>
<pre class="screen" id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_screen89566117363">SELECT * FROM ods_pub WHERE cast (pay_time AS timestamp) &gt;= 1;
SELECT cast (pay_time as timestamp) FROM obs_pub;</pre>
<p id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_p15573659173513"></p>
<p id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_p1376013223489"><strong id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_b6760102210485">Input Example: CAST</strong></p>
<pre class="screen" id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_screen127611222174820">select cast(ifnull(c1, 0) as string) from t1;
select cast(ifnull(c1, 0) as varchar) from t1;
select cast(ifnull(c1, 0) as double) from t1;
select cast(ifnull(c1, 0) as int) from t1;</pre>
<p id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_p0761222184812"><strong id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_b476142264814">Output</strong></p>
<pre class="screen" id="EN-US_TOPIC_0000001772696164__en-us_topic_0000001706224353_en-us_topic_0000001382527666_screen15761422154810">SELECT cast (ifnull (c1, 0) as varchar) FROM t1;
SELECT cast (ifnull (c1, 0) as varchar) FROM t1;
SELECT cast (ifnull (c1, 0) as double precision) FROM t1;
SELECT cast (ifnull (c1, 0) as int) FROM t1;</pre>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="dws_16_0103.html">MySQL Syntax Migrating</a></div>
</div>
</div>