达梦8与MySQL的主要区别 - xinwu-yang/cube-java GitHub Wiki
不支持 comment 注释
创建表的时候,不支持在列的后面直接加 comment 注释,使用 COMMENT ON IS 代替
COMMENT ON TABLE xxx IS xxx
COMMENT ON COLUMN xxx IS xxx
不支持 date_sub 函数
不支持 date_sub 函数,使用 dateadd(datepart,n,date) 代替, 其中,datepart可以为:year(yy,yyyy),quarter(qq,q),month(mm,m),dayofyear(dy,y),day(dd,d),week(wk,ww),weekday(dw),hour(hh), minute(mi,n), second(ss,s), millisecond(ms).
select dateadd(month, -6, now());
select dateadd(month, 2, now());
不支持 date_format 函数
它有三种代替方法
- 使用 datepart 代替:语法:datepart(datepart, date),返回代表日期的指定部分的整数,datepart可以为:year(yy,yyyy),quarter(qq,q),month(mm,m),dayofyear(dy,y),day(dd,d),week(wk,ww),weekday(dw),hour(hh),minute(mi,n),second(ss,s), millisecond(ms).
select datepart(year, '2018-12-13 08:45:00'); --2018
select datepart(month, '2018-12-13 08:45:00'); --12
- 使用 date_part 代替
使用 date_part 代替,功能和 datepart 一样,写法不同,参数顺序颠倒,且都要加引号.
select date_part('2018-12-13 08:45:00', 'year');--2018
select date_part('2018-12-13 08:45:00', 'mm'); -- 12
- 使用 extract 代替
使用 extract 代替,语法:extract(dtfield from date),从日期类型date中抽取dtfield对应的值dtfield 可以是 year,month,day,hour,minute,second.
select extract(year from '2018-12-13 08:45:00'); --2018
select extract(month from '2018-12-13 08:45:00'); --12
不支持 substring_index 函数
使用 substr / substring 代替
substr(char[,m[,n]])
substring(char[from m[ for n]])
不支持 group_concat 函数
使用 wm_concat 代替
select wm_concat(id) as idstr from persion ORDER BY id ;
不支持 from_unixtime 函数
使用 round 代替
round(date[,format])
不支持 case-when-then-else
select case when id = 2 then "aaa" when id = 3 then "bbb" else "ccc" end as test from (select id from person) tt;
current_timestamp 的返回值带有时区
select current_timestamp();
2018-12-17 14:34:18.433839 +08:00
convert(type, value) 函数
与 mysql 的 convert 一样,但是参数是反过来的,mysql 是 convert(value, type)
不支持 on duplicate key update
使用 merge into 代替
不支持 ignore
即 insert ignore into
不支持 replace into
使用 merge into 代替
不支持 if函数
不支持双引号
只支持单引号
不支持 auto_increment
使用 identity 代替
identity(1, 1),从 1 开始,每次增 1
不支持 longtext 类型
可用 CLOB 代替