Matt Rajkowski wrote:
The following FAILS in MySQL:
mysql> CREATE TABLE test (
-> something VARCHAR(200),
-> entered TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
-> modified TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL
-> );
ERROR 1293 (HY000): Incorrect table definition; there can be only one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT or ON UPDATE clause
yes, this not works, but there is a trick to skip this error.
first you define the table:
CREATE TABLE test (
something VARCHAR(200),
entered TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
modified TIMESTAMP);
and second you must define a trigger like to this:
CREATE TRIGGER test_entries BEFORE INSERT ON `test` FOR EACH ROW SET
NEW.entered = IFNULL(NEW.entered, NOW()),
NEW.modified = NEW.entered;
I've tested it and i think this works for centric
Marco Pancioni
Antica Bottega Digitale
www.abd.it