How to specify a default date/time with an HSQLDB timestamp

By Alvin J. Alexander, devdaily.com

When creating a database table in HSQLDB, here's an example that shows how to set a default value for a TIMESTAMP field:

create cached table directories (
  dir_id identity NOT NULL,
  directory varchar(255) NOT NULL,
  time timestamp default 'now'
);

There are other ways to do this, but the important line in the above SQL is this:

  time timestamp default 'now'

This is where I'm creating a field named "time" that automatically defaults to the current date/time when a record is created.


devdaily logo