如何使mysql表中的主键和当前时间戳列同步

如何使mysql表中的主键和当前时间戳列同步,mysql,sql,Mysql,Sql,我有一个带有模式的MySQL表tableA create table tableA( id bigint auto_increment primary key, data varchar(25), updated_at datetime default CURRENT_TIMESTAMP not null ); 创建新记录时,只有数据列将提供客户端的值。MySQL服务器将自动添加更新的 首先,我假设对于所有的行,id和updated_在列中是同步的 +----+-------+----

我有一个带有模式的MySQL表
tableA

create table tableA( 
id bigint auto_increment primary key, 
data varchar(25), 
updated_at datetime default CURRENT_TIMESTAMP not null 
);
创建新记录时,只有
数据
列将提供客户端的值。MySQL服务器将自动添加更新的

首先,我假设对于所有的行,id和updated_在列中是同步的

+----+-------+---------------------+
| id | data  |     updated_at      |
+----+-------+---------------------+
|  1 | ajith | 2020-01-07 00:00:00 |
|  2 | sql   | 2020-01-07 00:00:01 |
|  3 | query | 2020-01-07 00:00:02 |
+----+-------+---------------------+
从上表可以看出,如果x行的id>y行的id,那么x行的updated\u at也>=y行的updated\u at

但经过一些测试,我发现情况并非总是如此,甚至可能是这样

+----+-------+---------------------+
| id | data  |     updated_at      |
+----+-------+---------------------+
|  1 | ajith | 2020-01-07 00:00:00 |
|  2 | sql   | 2020-01-07 00:00:02 |
|  3 | query | 2020-01-07 00:00:01 |
+----+-------+---------------------+

在创建新记录时,有没有办法使这两列同步?

是单次插入(一次插入一个)还是批量插入(一次插入多个值或一次插入..选择)?CURRENT_TIMESTAMP不是每次在语句中都返回相同的时间戳吗?@P.Salmon它总是批量插入在创建新记录时有没有办法使这两列同步?1) 为什么这对你如此重要?2) 阅读。我指的是一个综合指数,而不是两个独立的指数。