[+] or [-] is an optional indicator indicating whether the interval is positive or negative (default is positive).
y is an optional parameter representing the number of years portion of the interval.
m is an optional parameter representing the number of months part of the interval. If you specify a number of years and months, you must include TO MONTH in the INTERVAL clause.
year_precision is an optional parameter used to specify the precision of year numbers (default is 2).
example
# 返回一个时间段SQL>selectinterval'1-3'yeartomonthfrom dual;INTERVAL'1-3'YEARTOMONTH
---------------------------------------------------------------------------+01-03# 可以进行运算操作SQL>select sysdate +interval'1-3'yeartomonthfrom dual;
SYSDATE+INTERVAL'1-
-------------------
2022-11-13 01:23:13
# 此处指定了duration列的精度为3,这就是说可以为该列的年数部分存储3位数字,所以报错提示:间隔的前导精度太小
SQL> select interval '2021' year(3) from dual;
select interval '2021' year(3)from dual
*
ERROR at line 1:
ORA-01873: the leading precisionof the intervalis too small