您可以这样做:
CREATE TABLE `ttt` (
`id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
`t1` TIMESTAMP NULL DEFAULT '0000-00-00 00:00:00',
`t2` TIMESTAMP NULL DEFAULT '0000-00-00 00:00:00',
`t3` TIMESTAMP NULL DEFAULT '0000-00-00 00:00:00',
`t4` TIMESTAMP NULL DEFAULT 0,
PRIMARY KEY (`id`)
) ENGINE=INNODB DEFAULT CHARSET=utf8;
- 由于TIMESTAMP值存储为大纪元,因此时间戳值'1970-01-01 00:00:00'(UTC)被保留,因为第二个#0用于表示'0000-00-00 00:00:00 '。
- 在MariaDB 5.5及更低版本中,每个表只能有一个TIMESTAMP列,其CURRENT_TIMESTAMP定义为其默认值。自MariaDB 10.0起,该限制不再适用。
参见:https : //mariadb.com/kb/en/mariadb/timestamp/
样品
MariaDB []> insert into ttt (id) VALUES (1),(2),(3);
Query OK, 3 rows affected (0.01 sec)
Records: 3 Duplicates: 0 Warnings: 0
MariaDB []> select * from ttt;
+
| id | t1 | t2 | t3 | t4 |
+
| 1 | 0000-00-00 00:00:00 | 2000-01-01 12:01:02 | 0000-00-00 00:00:00 | 0000-00-00 00:00:00 |
| 2 | 0000-00-00 00:00:00 | 2000-01-01 12:01:02 | 0000-00-00 00:00:00 | 0000-00-00 00:00:00 |
| 3 | 0000-00-00 00:00:00 | 2000-01-01 12:01:02 | 0000-00-00 00:00:00 | 0000-00-00 00:00:00 |
+
3 rows in set (0.00 sec)
MariaDB []>