当前位置:Gxlcms > 数据库问题 > oracle知识总结

oracle知识总结

时间:2021-07-01 10:21:17 帮助过:32人阅读

一、特殊函数

  1:NVL函数

    NVL(str1,str2),如果oracle第一个参数为空那么显示第二个参数的值,如果第一个参数的值不为空,则显示第一个参数本来的值;

    eg:select nvl(t.a, 0) from table t;

  2:NVL2函数

    NVL2(str1,str2, str3),如果该函数的第一个参数为空那么显示第二个参数的值,如果第一个参数的值不为空,则显示第三个参数的值;

    eg:select nvl(t.a, 1, -1) from table t;

  3:TRUNC函数

    3.1:trunc for date

      select trunc(sysdate) from dual; --系统日期当天2017/11/2  等价于 select trunc(sysdate, ‘dd‘) from dual;

      select trunc(sysdate, ‘yyyy‘) from dual; --今年第一天2017/1/1

      select trunc(sysdate, ‘mm‘) from dual; --这个月第一天2017/11/1

      select trunc(sysdate, ‘d‘) from dual; --本周第一天

    3.2:trunc for number

      select trunc(123.456) from dual; --123 直接从小数点截取,等价于select trunc(123.456, 0) from dual;

      

      

oracle知识总结

标签:ble   3.4   sel   第一个   select   总结   小数点   table   ber   

人气教程排行