如何在 mysql 中插入两个具有相同服务器时间的日期时间字段?

How to insert two datetime fields with same server time in mysql?

我有一个 table,其中有两个字段 insert_time 和 update_time。 insert_time 的类型是 varchar(30) NOT NULL DEFAULT ''update_time 的类型是 timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP.

insert into tableName(inser_time,update_time) values('2017-02-17 20:30:38')

会使update_time失去意义。

那么如果不更新Mysql版本,如何让两个字段在插入时具有相同的服务器时间?

是否将两个字段设置为相同的值?

insert into tableName(inser_time,update_time) 
values('2017-02-17 20:30:38','2017-02-17 20:30:38')

编辑以使用当前时间

insert into tableName(inser_time,update_time) 
values(now(), now())

编辑 2 来自 mysql 手册: https://dev.mysql.com/doc/refman/5.7/en/date-and-time-functions.html#function_now

Functions that return the current date or time each are evaluated only once per query at the start of query execution. This means that multiple references to a function such as NOW() within a single query always produce the same result.