P. 1
SQL Material

SQL Material

|Views: 354|Likes:
Published by Sravan Kumar

More info:

Published by: Sravan Kumar on Nov 23, 2011
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less

08/02/2014

pdf

text

original

Oracle supports two interval datatypes. Both were introduced
in Oracle9i Database, and both conform to the ISO SQL
standard.

INTERVAL YEAR to MONTH

Allows you to define and interval of time in terms of years and
months

INTERVAL DAY TO SECOND

Allows you to define an interval of time in terms of days,
hours, minutes and seconds (including fractional seconds).

Example

select (sysdate - to_date('10-jan-2004')) year to month
from dual

OUTPUT

+000000003-10

Analysis

Returns the difference. No of years and months between
both the dates.

Example

Select (sysdate - to_date('10-NOV-2007')) day to second from
dual

OUTPUT

+000000009 11:04:07

Analysis

Find the difference with days and time. For sysdate it takes
0.00 hrs as starting time

Siva Kumar HVK

93

Note :- We can also change the default format for a given
session using the ALTER SESSION command

SQL> ALTER SESSION SET NLS_DATE_FORMAT =
‘DD/MM/YYYY’;

SQL> SELECT SYSDATE FROM DUAL:

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->