MYSQL last_insert_id() and concurrency(MYSQL last_insert_id() 和并发)
问题描述
我有一个简单的 MYSQL 问题.如果我在一个网页上运行 INSERT QUERY 之后立即执行包含 LAST_INSERT_ID() 的查询,该网页有许多并发用户访问执行 INSERT的其他页面strong>LAST_INSERT_ID() 的值是否会被掺假/损坏?
I have a simple MYSQL question. If I make a query that contains LAST_INSERT_ID() right after an INSERT QUERY running on a web page which has many concurrent users accessing other pages that perform INSERT operations would the value of LAST_INSERT_ID() be adulterated/corrupted?
推荐答案
不,它会从当前连接返回插入 id.只要您的脚本没有进行任何其他插入,您就会得到您想要的.
No, it will return the insert id from the current connection. As long as your script hasn't made any other inserts, you will get the one you want.
另请注意,这只会返回生成的 ID(例如自动增量).如果您创建自己的 ID,它不会返回给您.
Also be aware that this will only return a generated ID (e.g. an auto-increment). If you are creating your own ID's it won't return this to you.
这篇关于MYSQL last_insert_id() 和并发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:MYSQL last_insert_id() 和并发
基础教程推荐
- 什么是 orradiag_<user>文件夹? 2022-01-01
- 在多列上分布任意行 2021-01-01
- 二进制文件到 SQL 数据库 Apache Camel 2021-01-01
- 如何在 SQL 中将 Float 转换为 Varchar 2021-01-01
- oracle区分大小写的原因? 2021-01-01
- 如何根据该 XML 中的值更新 SQL 中的 XML 2021-01-01
- 在 MySQL 中:如何将表名作为存储过程和/或函数参数传递? 2021-01-01
- MySQL 中的类型:BigInt(20) 与 Int(20) 2021-01-01
- mysql选择动态行值作为列名,另一列作为值 2021-01-01
- 表 './mysql/proc' 被标记为崩溃,应该修复 2022-01-01
