Mega Code Archive

 
Categories / Oracle PLSQL Tutorial / SQL Data Types
 

Using the INTERVAL DAY TO SECOND Type

INTERVAL DAY TO SECOND type stores time intervals measured in days and seconds. SQL> SQL> CREATE TABLE myTable (   2    id INTEGER,   3    duration INTERVAL DAY(3) TO SECOND (4)   4  ); Table created. SQL> SQL> desc myTable;  Name          Null?    Type  ID                     NUMBER(38)  DURATION               INTERVAL DAY(3) TO SECOND(4) SQL> SQL> drop table myTable; Table dropped. A precision of 3 for the day and a precision of 4 for the fractional seconds of the duration column means up to three digits may be stored for the day of the interval and up to four digits to the right of the decimal point for the fractional seconds. An INTERVAL DAY TO SECOND literal value: INTERVAL '[+|-][d] [h[:m[:s]]]' [DAY[(days_precision)]]) [TO HOUR | MINUTE | SECOND[(seconds_precision)]] where + or - is an optional indicator that specifies whether the time interval is positive or negative (default is positive). d is the number of days for the interval. h is the optional number of hours for the interval; if you supply days and hours, you must include TO HOUR in your literal. m is the optional number of minutes for the interval; if you supply days and minutes, you must include TO MINUTES in your literal. s is the optional number of seconds for the interval; if you supply days and seconds you must include TO SECOND in your literal. days_precision is the optional precision for the days (default is 2). seconds_precision is the optional precision for the fractional seconds (default is 6). Quote from: Oracle Database 10g SQL (Osborne ORACLE Press Series) (Paperback) # Paperback: 608 pages # Publisher: McGraw-Hill Osborne Media; 1st edition (February 20, 2004) # Language: English # ISBN-10: 0072229810 # ISBN-13: 978-0072229813