Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

interval function in oracle

Tags:

sql

oracle

Query:

SELECT INTERVAL '300' month,
       INTERVAL '54-2' year to month,
       INTERVAL ' 11:12:10.1234567' hour to second 
  FROM DUAL;

The output of the above query is:

+25-00,+54-02,+00 11:12:10.1234567

Can someone please explain to me how this query is giving this output, with an explanation about the interval function?

like image 747
Aaaaa Avatar asked May 04 '11 06:05

Aaaaa


1 Answers

INTERVAL is not a function it's a keyword that introduces an interval literal and such denotes a data type. Similar to what the literals DATE '2011-05-04' or TIMESTAMP '2011-05-04 17:18:19' are doing.

Details about interval literals
http://docs.oracle.com/cd/E11882_01/server.112/e41084/sql_elements003.htm#SQLRF00221
http://docs.oracle.com/cd/E11882_01/server.112/e41084/expressions009.htm#SQLRF52084

Details about the interval datatype:
http://docs.oracle.com/cd/E11882_01/server.112/e41084/sql_elements001.htm#i128552

like image 171
a_horse_with_no_name Avatar answered Sep 20 '22 15:09

a_horse_with_no_name