When you run
SHOW FULL COLUMNS FROM `moufa`; -- where `moufa` is the name of the table in the example
you will be able to see something like this
+-------+-------------+-----------+------+-----+---------------------+-------------------------------+---------------------------------+---------+
| Field | Type | Collation | Null | Key | Default | Extra | Privileges | Comment |
+-------+-------------+-----------+------+-----+---------------------+-------------------------------+---------------------------------+---------+
| id | smallint(6) | NULL | NO | PRI | NULL | auto_increment | select,insert,update,references | |
| ts | timestamp | NULL | NO | | current_timestamp() | on update current_timestamp() | select,insert,update,references | |
+-------+-------------+-----------+------+-----+---------------------+-------------------------------+---------------------------------+---------+
The problem is on the ts
field the Extra
. To check your the table run
SHOW CREATE TABLE `moufa`;
The most common case like GMB posted the column has been auto-updated.
Now to avoid further cases like this, you should explicitly define the the default value for the column.
DROP TABLE IF EXISTS `moufa`; -- just for the example
CREATE TABLE `moufa`(
`id` SMALLINT NOT NULL AUTO_INCREMENT,
`ts` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY(`id`)
);
Or rather than dropping and recreating a table
ALTER TABLE `moufa`
MODIFY COLUMN `ts` TIMESTAMP DEFAULT CURRENT_TIMESTAMP;