例子:
- 以下“(9)”这块无需替换,可以根据需要替换“1”或者“ ‘2’ ”即可。
-- 年份运算(当前时间-2年)
SELECT SYSDATE - (1 * INTERVAL '2' YEAR(9)) AS YEAR_OPERATION FROM DUAL;
-- 月份运算(当前时间-2个月)
SELECT SYSDATE - (1 * INTERVAL '2' MONTH(9)) AS MONTH_OPERATION FROM DUAL;
-- 天数运算(当前时间-2天)
SELECT SYSDATE - (1 * INTERVAL '2' DAY(9)) AS DAY_OPERATION FROM DUAL;
-- 小时运算(当前时间-2小时)
SELECT SYSDATE - (1 * INTERVAL '2' HOUR(9)) AS HOUR_OPERATION FROM DUAL;
-- 分钟运算(当前时间-2分钟)
SELECT SYSDATE - (1 * INTERVAL '2' MINUTE(9)) AS MINUTE_OPERATION FROM DUAL;
-- 秒钟运算(当前时间-2秒钟)
SELECT SYSDATE - (1 * INTERVAL '2' SECOND(9)) AS SECOND_OPERATION FROM DUAL;
Oracle Database 9i数据库引入了一种新特性,可以用来存储时间间隔。
INTERVAL语法: