MySql TIMESTAMP column is auto updated. Why?

后端 未结 2 1964
野的像风
野的像风 2021-01-18 10:39

I have a table created with this SQL:

CREATE TABLE `test_table` (
  `id` BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
  `data` TEXT,
  `timestamp` TIMESTAMP
)         


        
2条回答
  •  遥遥无期
    2021-01-18 10:58

    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
    ) ...
    

提交回复
热议问题