我可以肯定的Mysql的最后插入标识? [英] Can I be sure of Last Insert Id of Mysql?

查看:124
本文介绍了我可以肯定的Mysql的最后插入标识?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有连接器/网络的最新版本。

I have the latest version of Connector/Net.

我知道有的MySqlCommand 的属性名为 LastInsertedId

我可以肯定的是它返回最后插入的ID?我的意思是,当同时有两个插片,我可以肯定,我会得到正确的价值?

Can I be sure that it returns last insert id? I mean, when there are two inserts simultaneously, can I be sure that I'll get the right value?

我从来没有使用该属性。现在我设计一个新的博客功能,在我的网站。

I've never used that property. Now I'm designing a new blogging feature in my website.

那么,如果两个终端用户,通过巧合的是,在同一时间创建的博客,我可以一定要得到正确的价值?

So , if two end users, through coincidence, create blogs at the same time, can I be sure to get the right value?

推荐答案

您将需要一个单独的数据库连接/会话为每个用户/会话登录到Web服务器。

You'll want a separate database connection/session for each user/session logged into your web server.

LAST_INSERT_ID 返回当前连接/会话的最后一个自动增量值。

LAST_INSERT_ID returns the last autoincrement value for the current connection/session.

这篇关于我可以肯定的Mysql的最后插入标识?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆