Page 1 of 1

can't do "DEFAULT NOW()"

Posted: Thu Jan 05, 2006 10:58 pm
by RobertPaul
Trying to make some mySQL tables, and this query isn't cooperating:

Code: Select all

CREATE TABLE news (
  id SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT,
  news_time DATETIME NOT NULL DEFAULT NOW(),
  content TEXT NOT NULL,
  author VARCHAR(45) NOT NULL DEFAULT Tempus,
  PRIMARY KEY(id)
);
It doesn't seem to like setting NOW() as the default value. I'm pretty sure I've done this before, so I can't figure what the problem is. mySQL version is 4.0, if it matters...

Posted: Thu Jan 05, 2006 11:00 pm
by feyd
it doesn't support it. Using a field type of TIMESTAMP will do a it (no default needed).. however, the timestamp will change with each update to the record (unless you explicitly set the field)

Posted: Thu Jan 05, 2006 11:02 pm
by RobertPaul
Hmm ... alright, thanks!