SELECT TO_CHAR(SYSDATE, 'YYYY-MM-DD HH24:MI:SS') FROM DUAL;
SELECT TO_DATE('2018-07-20 14:41:27', 'YYYY-MM-DD HH24:MI:SS') FROM DUAL;
SELECT TO_CHAR(SYSDATE, 'yyyy') - TO_CHAR(T.BIRTHDAY, 'yyyy') AGE FROM TABLE T;
-- 取(0,1)之间的小数
SELECT DBMS_RANDOM.VALUE FROM DUAL;
-- 取0或1,四舍五入
SELECT ROUND(DBMS_RANDOM.VALUE) FROM DUAL;
-- 圆周率π
SELECT ACOS(-1) FROM DUAL; -- 3.14159265358979
-- FLOOR:取整数位
SELECT FLOOR(2345.67) FROM DUAL; -- 2345
-- CEIL:大于或等于的最小整数
SELECT CEIL(3.1415927) FROM DUAL; -- 4
-- ROUND:四舍五入
SELECT ROUND(3.1415926) FROM DUAL; -- 3
SELECT ROUND(3.1415926,4) FROM DUAL; -- 3.1416
-- TRUNC:截取指定精度
SELECT TRUNC(3.1415926) FROM DUAL; -- 3
SELECT TRUNC(3.1415926,4) FROM DUAL; -- 3.1415
参考资料