background image
<< DATE data type | DOUBLE PRECISION data type >>

DECIMAL data type

<< DATE data type | DOUBLE PRECISION data type >>
Derby Reference Manual
197
Syntax
DATE
Corresponding compile-time Java type
java.sql.Date
JDBC metadata type (java.sql.Types)
DATE
Dates, times, and timestamps must not be mixed with one another in expressions.
Any value that is recognized by the java.sql.Date method is permitted in a column of the
corresponding SQL date/time data type. Derby supports the following formats for DATE:
yyyy-mm-dd
mm/dd/yyyy
dd.mm.yyyy
The first of the three formats above is the java.sql.Date format.
The year must always be expressed with four digits, while months and days may have
either one or two digits.
Derby also accepts strings in the locale specific datetime format, using the locale of the
database server. If there is an ambiguity, the built-in formats above take precedence.
Examples
VALUES DATE('1994-02-23')
VALUES '1993-09-01'
DECIMAL data type
DECIMAL provides an exact numeric in which the precision and scale can be arbitrarily
sized. You can specify the precision (the total number of digits, both to the left and
the right of the decimal point) and the scale (the number of digits of the fractional
component). The amount of storage required is based on the precision.
Syntax
{ DECIMAL | DEC } [(precision [, scale ])]
The precision must be between 1 and 31. The scale must be less than or equal to the
precision.
If the scale is not specified, the default scale is 0. If the precision is not specified, the
default precision is 5.
An attempt to put a numeric value into a DECIMAL is allowed as long as any
non-fractional precision is not lost. When truncating trailing digits from a DECIMAL value,
Derby rounds down.
For example:
-- this cast loses only fractional precision
values cast (1.798765 AS decimal(5,2));
1
--------
1.79
-- this cast does not fit
values cast (1798765 AS decimal(5,2));
1