Reputation: 2361
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 !
Upvotes: 4
Views: 5850
Reputation: 65577
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
Upvotes: 3