background image
<< TIME data type | XML data type >>

User-defined types

<< TIME data type | XML data type >>
Derby Reference Manual
203
TIMESTAMP stores a combined DATE and TIME value to be stored. It permits a
fractional-seconds value of up to nine digits.
Syntax
TIMESTAMP
Corresponding compile-time Java type
java.sql.Timestamp
JDBC metadata type (java.sql.Types)
TIMESTAMP
Dates, times, and timestamps cannot be mixed with one another in expressions.
Derby supports the following formats for TIMESTAMP:
yyyy-mm-dd hh:mm:ss[.nnnnnn]
yyyy-mm-dd-hh.mm.ss[.nnnnnn]
The first of the two formats above is the java.sql.Timestamp format.
The year must always have four digits. Months, days, and hours may have one or two
digits. Minutes and seconds must have two digits. Nanoseconds, if present, may have
between one and six 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 '1960-01-01 23:03:20'
VALUES TIMESTAMP('1962-09-23 03:23:34.234')
VALUES TIMESTAMP('1960-01-01 23:03:20')
User-defined types
Derby allows you to create user-defined types. A user-defined type is a serializable
Java class whose instances are stored in columns. The class must implement the
java.io.Serializable interface.
For information on creating and removing types, see
CREATE TYPE statement
and
DROP TYPE statement
. See
GRANT statement
and
REVOKE statement
for information
on usage privileges for types.
For information on writing the Java classes that implement user-defined types, see
"Programming user-defined types" in the Derby Developer's Guide.
VARCHAR data type
VARCHAR provides for variable-length storage of strings.
Syntax
{ VARCHAR | CHAR VARYING | CHARACTER VARYING }(length)
length is an unsigned integer constant. The maximum length for a VARCHAR string is
32,672 characters.
Corresponding compile-time Java type
java.lang.String
JDBC metadata type (java.sql.Types)