数据库函数比较:修订间差异

来自牛奶河Wiki
跳到导航 跳到搜索
(创建页面,内容为“=== MySQL - Doris === {| class="wikitable" |Type |MySQL |Doris |Result |- |Json |select   j1 -> '$."v1"' from     (         select   cast('{"v1":"10", "v2":"11"}' as json)  j1         ) o <nowiki>;</nowiki> | |"10" |- |Json |select   JSON_EXTRACT(cast('{"v1":"10", "v2":"11"}' as json), '$."v1"') |= |"10" |- |String |select   trim('"10"', '"') |= |10 |- | | | | |}”)
 
无编辑摘要
第1行: 第1行:
=== MySQL - Doris ===
=== Json ===
{| class="wikitable"
{| class="wikitable"
|Type
|Type
第29行: 第29行:
|
|
|
|
|}
=== Date ===
{| class="wikitable"
|
|MySQL
|Clickhouse
|Oracle
|Result
|-
|转字符串
|date_format(now(), '%Y%m%d%H%m%S')
|toYYYYMMDDhhmmss(now())
|to_char(sysdate, 'yyyymmddhh24miss')
|20231129103552
|-
|日期增
|adddate(now(), 10)
|date_add(day, 10, now())
|sysdate + 10
|2023/11/19 10:18:10
|-
|日期减
|subdate(now(), 10)
|date_sub(day, 10, now())
|sysdate - 10
|2023/12/9 10:16:22
|}
=== Rand ===
{| class="wikitable"
|
|MySQL
|Clickhouse
|Oracle
|Result
|-
|随机数
|cast(rand() * 1000 as int)
|trunc(rand()/10000000)
|dbms_random.value(0,1000)
|121
|}
|}

2023年11月29日 (三) 10:57的版本

Json

Type MySQL Doris Result
Json select   j1 -> '$."v1"'

from     (         select   cast('{"v1":"10", "v2":"11"}' as json)  j1         ) o ;

"10"
Json select   JSON_EXTRACT(cast('{"v1":"10", "v2":"11"}' as json), '$."v1"') = "10"
String select   trim('"10"', '"') = 10

Date

MySQL Clickhouse Oracle Result
转字符串 date_format(now(), '%Y%m%d%H%m%S') toYYYYMMDDhhmmss(now()) to_char(sysdate, 'yyyymmddhh24miss') 20231129103552
日期增 adddate(now(), 10) date_add(day, 10, now()) sysdate + 10 2023/11/19 10:18:10
日期减 subdate(now(), 10) date_sub(day, 10, now()) sysdate - 10 2023/12/9 10:16:22

Rand

MySQL Clickhouse Oracle Result
随机数 cast(rand() * 1000 as int) trunc(rand()/10000000) dbms_random.value(0,1000) 121