mysql timestamp type field automatically updates the time

The following two table building statements have the same effect:

the following is the code snippet:
CREATE TABLE `test` (
`t1` TIMESTAMP NOT NULL ,
`ww` VARCHAR( 5 ) NOT NULL
) ENGINE = MYISAM
CREATE TABLE `test` (
  `t1` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
  `ww` varchar(5) NOT NULL
) ENGINE=MyISAM ;


Here is the code snippet:
Automatic initialization and update:
ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
only automatic initialization:
ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP
only automatic update
ts TIMESTAMP DEFAULT 0 ON UPDATE CURRENT_TIMESTAMP
just give a constant (note: 0000-00-00 00:00 :00)
ts TIMESTAMP DEFAULT 0

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326562397&siteId=291194637