Вы находитесь на странице: 1из 1

10 Chapter 1: Creating

information from the column statistics for columns with a declared maximum
size less than 8 bytes. Some of these topics are discussed in Chapter 10,
Tuning.
Otherwise, a string is still a string, and you can happily store and copy and
assign values with different declared string types without any problems.

1.5.2 Dates and Times


Date and time values can be input and displayed in many different external for-
mats, but they are always stored in one of three fixed physical formats. The
DATE data type requires 4 bytes to store the numeric year, month and day. The
TIME data type requires 8 bytes to store the numeric hour, minute, second, and
fraction of a second up to six decimal places. The TIMESTAMP data type also
requires 8 bytes to store numeric year, month, day, hour, minute, second, and
fraction of a second.
<date_time_type> ::= DATE
| TIME
| TIMESTAMP
The TIME data type supports the range 00:00:00.000000 to 23:59:59.999999,
and DATE supports 0001-01-01 to 9999-12-31. The TIMESTAMP data type
fully supports the range 1600-02-28 23:59:59 to 7911-01-01 00:00:00. Outside
this range, the date portion supports years from 1 to 9999 but the time portion
may not be complete.
On some platforms CURRENT TIME and CURRENT TIMESTAMP will
only return two or three significant digits to the right of the decimal point in the
seconds portion. However, TIME and TIMESTAMP columns are always capa-
ble of storing all six digits.

Tip: Use SET OPTION PUBLIC.TIME_FORMAT = 'HH:NN:SS.SSSSSS' and SET


OPTION PUBLIC.TIMESTAMP_FORMAT = 'YYYY MM DD HH:NN:SS.SSSSSS' to
retrieve all six digits from the database, even if they are zero. The default is three
digits, which means even if you store more you cant retrieve them into your
application.

1.5.3 Exact Decimals


Exact decimals give exact results when they are combined in arithmetic expres-
sions, making them ideal for financial calculations.
The DECIMAL and NUMERIC data types are one and the same: an exact
decimal number up to 127 digits in length (the precision). The number of digits
to the right of the decimal point (the scale) can range from zero to all of the
digits.
<exact_numeric_type> ::= <exact_keyword>
[ "(" <exact_precision> [ "," <exact_scale> ] ")" ]

<exact_keyword> ::= DEC


| DECIMAL
| NUMERIC
<exact_precision> ::= integer literal in the range 1 to 127
<exact_scale> ::= integer literal in the range 1 to <exact_precision>

Вам также может понравиться