can't do "DEFAULT NOW()"

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
RobertPaul
Forum Contributor
Posts: 122
Joined: Sun Sep 18, 2005 8:54 pm
Location: OCNY

can't do "DEFAULT NOW()"

Post 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...
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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)
RobertPaul
Forum Contributor
Posts: 122
Joined: Sun Sep 18, 2005 8:54 pm
Location: OCNY

Post by RobertPaul »

Hmm ... alright, thanks!
Post Reply