I have a table created with this SQL:
CREATE TABLE `test_table` (
`id` BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
`data` TEXT,
`timestamp` TIMESTAMP
) CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE InnoDB;
But when I run SHOW CREATE TABLE test_table
, I get:
CREATE TABLE `test_table` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`data` text COLLATE utf8_unicode_ci,
`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci
Why the timestamp column being assigned ON UPDATE CURRENT_TIMESTAMP by default? I do not know how to get rid of this. Any help would be greatly appreciated.
If you want that to your timestamp
will be not added automatically ON UPDATE
you have to define it like this
CREATE TABLE `test_table` (
...
`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
) ...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With