The behavior of TIMESTAMP in MySQL 5.5:
1. The implicit default value of the first TIMESTAMP NOT NULL field without a default value: CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
2. The implicit default value of the TIMESTAMP NOT NULL field with no default value set later: 0000-00-00 00:00:00
3. The table creation statement that does not support multiple CURRENT_TIMESTAMP default values of 5.5 is similar to this:
CREATE TABLE `audit_log` ( `id` int ( 10 ) unsigned NOT NULL AUTO_INCREMENT, `ent_id` int ( 10 ) unsigned NOT NULL DEFAULT ' 0 ' , `rule_id` int ( 10 ) unsigned NOT NULL DEFAULT ' 0 ' , rules_detail` VARCHAR `( 2048 ) the NOT NULL the DEFAULT '' the COMMENT ' rule details ' , sender_email` VARCHAR `( 512 ) the NOT NULL the DEFAULT '' the COMMENT ' Sender mail review ' , `receiver_email` varchar( 512 ) NOT NULL DEFAULT '' COMMENT'recipient 's mailbox ' , subject` VARCHAR `( 512 ) the NOT NULL the DEFAULT '' the COMMENT ' theme ' , `createtime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `start_time` timestamp NOT NULL DEFAULT ' 0000-00-00 00:00:00 ' , `end_time` timestamp NOT NULL DEFAULT ' 0000-00-00 00:00:00 ' , status` tinyint `( 3 ) the NOT NULL the DEFAULT unsigned ' 1 ' the COMMENT ' current state (by 1, 2 rejected rejected timeout 3, 4 by timeout) ' , reviewer_leader` VARCHAR `( 512 ) the NOT NULL the DEFAULT '' the COMMENT ' moderator ' , PRIMARY KEY (`id`), KEY `idx_ent_id` (`ent_id`) ) ENGINE =InnoDB DEFAULT CHARSET=utf8 COMMENT = ' Audit log table '
The behavior of TIMESTAMP in MySQL 5.6:
Supports multiple CURRENT_TIMESTAMP default values, but does not support setting the default value to 0000-00-00 00:00:00
5.6 can be like this:
`createtime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `start_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `end_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
Read More:
- MYSQL: CURRENT_TIMESTAMP & ON UPDATE CURRENT_TIMESTAMP
- MYSQL Create TIMESTAMP and Save Error: ERROR 1067 (42000): Invalid default value for ‘last_updated_on’
- [Solved]ERROR 1067 (42000): Invalid default value for ‘end_time‘ Mysql
- [Solved] MySQL5.6.44 [Err] 1067 – Invalid default value for create_date settlement programme
- Mysql ERROR 1067: Invalid default value for ‘date’ [How to Solve]
- How to Solve mysql [Err] 1067-Invalid default value for
- [Solved] MySQL: datetime (0) null default NULL
- mysql workbench Error Code: 1046. No database selected Select the default DB to be used by doubl
- Mybatis Add Datas error: ERROR: Field * doesn‘t have a default value
- Mysql Flashback Warning: C:\Program Files\MySQL\MySQL Server 8.0\bin\mysql.exe
- [Solved] There is a problem with mysql8.0 without password in Navicat connection
- [Solved] ERROR 2002 (HY000): Can’t connect to local MySQL server through socket’/var/lib/mysql/mysql.sock’ (2)
- MySql Install Error: Can‘t connect to local MySQL server through socket ‘/tmp/mysql.sock‘
- Error 1406 (22001) in MySQL: data too long for column (Fixed)
- [Solved] MYSQL Command Execute Error: Can ‘t connect to local MySQL server through socket ‘/tmp/mysql.sock ‘(2) “
- (Fixed) workbench MySQL Error Code: 2013. Lost connection to MySQL server during query
- How to Fix MySQL error 1005: can’t create table (errno: 150)
- How to Solve can‘t connect to local mysql server through socket ‘/var/lib/mysql/mysql.sock‘
- [Solved] CentOS installs MySQL and starts MySQL with error 2002 (HY000)
- [Solved] Django configures MySQL Error: NameError: name ”_MySQL ‘is not defined