小结: 1.注意使用限制 Locking reads are only possible when autocommit is disabled (either by beginning transaction with START TRANSACTION or by setting autocommit to 0. SELECT ... FOR UPDATE or SELECT ... FOR SHARE MySQL :: MySQL 8.0 Reference Manual :: 15.7.
LAST_INSERT_ID 自动返回最后一个 INSERT 或 UPDATE 操作为 AUTO_INCREMENT 列设置的第一个发生的值. 参考这里 The ID that was generated is maintained in the server on a per-connection basis. LAST_INSERT_ID是基于单个connection的, 不可能被其它的客户端连接改变. 可以用 SELECT LAST_INSERT_ID(); 查询LAST_INSERT_I