oracle迁移到mysql数据库的简单对比
oraclemysql||
‘dept_’||name
concat(str1,str2,…)) ,参数含有null,会返回null,所以对oracle里面参数要使用ifnull函数判断是否为空
concat('dept_',ifnull(name,''))
decode(条件,值1,返回值1,值2,返回值2,…值n,返回值n,缺省值)
decode(city,0,'否',1,'是')case when then else end ? ? ? ? ? else后面是没有对应条件,设置的值
case city when 0 then '否' when 1 then '是' end
sysdate ?获得现在时间
now()或者SYSDATE()
NVL (expr1, expr2):expr1为NULL,返回expr2;不为NULL,返回expr1。注意两者的类型要一致?
ifnull()
NVL2 (expr1, expr2, expr3) :expr1不为NULL,返回expr2;为NULL,返oracle账号回expr3。expr2和expr3类型不同的话,expr3会转换为expr2的类型?
nvl2(status,1,0)
if()和ifnull()配合实现
if(expr1,expr2,expr3)?expr1 为0或者null或者false,则返回 expr3 ; 否则,返回expr2;
if(ifnull(status,false),1,0)
to_char(date,'yyyy-MM-dd hh24:mm:ss')
to_data(date.time,'yyyy-MM-dd?')
1.?date_format(date,'%Y-%m-%d')
1.?tr_to_date(date,'%Y-%m-%d')?
列名 desc?nulls last?
?My SQL 默认NULL 为最小order by order_col [asc|desc] nulls [first|last]order by IF(ISNULL(my_field),1,0),my_field;
trunc()截数字时?
?truncate()代替
TO_NUMBER(str)?
CAST("123" AS SIGNED INTEGER)
2个日期相减(D1-D2)
DATEDIFF(date1,date2)
rownum
SELECT @rownum:=@rownum+1 AS rownum, table.* FROM (SELECT @rownum:=0) r,table;