- the difference between two datetime values


      * INTERVAL YEAR () TO MONTH

      * INTERVAL DAY () TO SECOND ()


    - interval literals ==> http://goo.gl/J1UDm



select interval '123-9' year to month from dual;

==> ERROR : ORA-01873: the leading precision of the interval is too small


select interval '123-9' year(3) to month(2) from dual;

==> ERROR : ORA-00923: FROM keyword not found where expected



select interval '123-11' year(3) to month from dual;

select interval '123-12' year(3) to month from dual;

==> ERROR : ORA-01843: not a valid month



select interval '123--11' year(3) to month from dual;

==> ERROR : ORA-01867: the interval is invalid


select interval '123+10' year(3) to month from dual;

==> ERROR : ORA-01867: the interval is invalid


select interval '123 7' year(3) to month from dual;

==> ERROR : ORA-01867: the interval is invalid



select interval '123' year(3) to month from dual;

==> ERROR : ORA-01867: the interval is invalid

select interval '123-0' year(3) to month from dual;

select interval '123' year(3) from dual;


select interval '6' to month from dual;

==> ERROR: ORA-30089: missing or invalid <datetime field>

select interval '6' month from dual;



select current_date

    , current_date + interval '1-1' year to month as p_p

    , current_date - interval '-1-1' year to month as m_m

    , current_date + interval '-1-1' year to month as p_m

    , current_date - interval '1-1' year to month as m_p

from dual;



select interval '1:10:12' hour to second from dual;

'Oracle > SQL Fundamentals II' 카테고리의 다른 글

14일차 # Example  (0) 2012.04.23
14일차 # 5-20: INTERVAL fields  (0) 2012.04.23
14일차 # 5-12: TIMESTAMP Fields  (0) 2012.04.23
14일차 # 5-10: Timestamp Data Type  (0) 2012.04.23
14일차 # Datetime  (0) 2012.04.23

+ Recent posts