Team Fly 

Page 11

Number Specification

Column Length

Decimal Digits

(3,2)

3

2

(6,3)

6

3

(17,12)

17

12

TABLE 1-1. Number Data Type Specification

The secret here is that the integer portion of a number data type where decimal places are specified is the difference between the two numbers. As Table 1-1 illustrates, the specification (9,4) allows for five, not nine, integer digits. If more decimal digits are received than the column definition permits, it rounds the value before storage.

date

The date data type stores time and date information, with the time component rounded to the nearest full second. There are many, many functions performed on date fields as they are extracted from an Oracle Database 10g. Even though we supposedly learned something during the millennium issues associated with the year 2000, we still commonly use a two-digit year designator.

As date columns are extracted from the Oracle Database 10g, it is common to perform a function on their values to make them more readable. By default, the time component of a date column is not displayed without manipulating its contents using a to_char function described in Chapter 2.

timestamp

The timestamp data type is a close relative of date. There is a time component in this data type, displayed with the data without the need for the to_char function. This listing illustrates this concept:

SQL> create table timestamp_test (ts timestamp);
Table created.
SQL> insert into timestamp_test values (sysdate);
1 row created.
SQL> select * from timestamp_test;
TS
---------------------------------------------------------------------------
14-DEC-06 05.25.07.000000 PM
SQL> create table date_test (d date);
Table created.
SQL> insert into date_test values (sysdate);
1 row created.
Team Fly 
0030