4

I want to add expire TIMESTAMP in DB table. I have one field timestamp with type TIMESTAMP and default value CURRENT_TIMESTAMP(). I adding new field "expire" with type DATETIME with default value ADDDATE(CURRENT_TIMESTAMP, INRERVAL 1 DAY), but not working.

CREATE TABLE IF NOT EXISTS `temp_mch` (
  `name` varchar(60) NOT NULL,
  `qty_new` int(5) NOT NULL,
  `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`name`),
  KEY `name` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1

Where I'm wrong ?

Thanks in advance !

dido
  • 2,330
  • 8
  • 37
  • 54

1 Answers1

3

That is not supported in the column default definition.

You can use a trigger to do it instead.

See this question for details:

Expire date as default value for TIMESTAMP column

Community
  • 1
  • 1
Ike Walker
  • 64,401
  • 14
  • 110
  • 109