Date, Time, and Timestamp Defaults

For columns with the DATE, TIME, or TIMESTAMP data type, you can use the CURRENT DATE, CURRENT TIME, TIMESTAMP, or CURRENT TIMESTAMP special value as a default. The default you choose must be compatible with the data type of the column.

CURRENT DATE Default

A CURRENT DATE default might be useful to record:

  • Dates of phone calls in a contact database

  • Dates of orders in a sales entry database

  • The date a patron borrows a book in a library database

CURRENT TIMESTAMP Default

The CURRENT TIMESTAMP is similar to the CURRENT DATE default, but offers greater accuracy. For example, a user of a contact management application may have several contacts with a single customer in one day; the CURRENT TIMESTAMP default is useful for distinguishing between these contacts.

Since CURRENT TIMESTAMP records a date and the time down to a precision of millionths of a second, you may also find CURRENT TIMESTAMP useful when the sequence of events is important in a database.

TIMESTAMP Default

When a column is declared with DEFAULT TIMESTAMP, a default value is provided for insert and load operations. The value is updated with the current date and time whenever the row is updated.

On INSERT and LOAD, DEFAULT TIMESTAMP has the same effect as CURRENT TIMESTAMP. On UPDATE, if a column with a default value of TIMESTAMP is not explicitly modified, the value of the column is changed to the current date and time.

SAP Sybase IQ does not support default values of UTC TIMESTAMP or CURRENT UTC TIMESTAMP, nor does SAP Sybase IQ support the database option DEFAULT_TIMESTAMP_INCREMENT. SAP Sybase IQ generates an error every time an attempt is made to insert or update the default value of a column of type UTC TIMESTAMP or CURRENT UTC TIMESTAMP.