MySQL与Oracle常用函数

  • 日期转字符串
// Oracle
to_char(sysdate,'yyyy-MM-dd HH24:mm:ss')

// MySQL
select date_format(now(),'%Y-%m-%d %H:%i:%s')
  • 数字转字符串
//Oracle
to_char(1)

//MySQL
select cast(number as char)  / select cast(123 as char)
select concat(123,'')
  • 字符串转数字
//Oracle
to_number(sort)

//MySQL
cast(sort as signed integer)
  • 2个字符串返回一个非空的 (NULL)
//Oracle
select NVL(expr1,expr2)

//MySQL
select ifnull(expr1,expr2)

 

posted @ 2020-11-18 00:47  枫雪奕  阅读(125)  评论(0编辑  收藏  举报