The TIMESTAMP
datatype is an extension of the DATE
datatype. It stores the year, month, and day of the DATE
datatype, plus hour, minute, and second values. This datatype is useful for storing precise time values. Specify the TIMESTAMP
datatype as follows:
TIMESTAMP [(fractional_seconds_precision)]
where fractional_seconds_precision
optionally specifies the number of digits Oracle stores in the fractional part of the SECOND
datetime field. When you create a column of this datatype, the value can be a number in the range 0 to 9. The default is 6. When you specify TIMESTAMP
as a literal, the fractional_seconds_precision
value can be any number of digits up to 9, as follows:
TIMESTAMP'1997-01-31 09:26:50.124'
例子:
默认秒的小数位为6
select TO_CHAR(SYSTIMESTAMP,'YYYY/MM/DD HH24:MI:SS.FF') from dual
指定秒的小数位为9
select TO_CHAR(SYSTIMESTAMP(9),'YYYY/MM/DD HH24:MI:SS.FF9') from dual