在 SQL Server Management Studio 2008 中编辑数据行时是否会锁定数据行?
当我右键单击 SQL Server Management Studio 中的表并选择“编辑前 200 行”时,我正在查看的数据在什么时候(如果有的话)会被锁定?
我的一位同事表示,以这种方式查看数据时,可以锁定数据行(我想当他说如果将光标放在一行上并开始编辑数据时)。
这是在此上下文中唯一一次可以锁定数据吗?
When I right-click on a table in SQL Server Management Studio and choose 'Edit top 200 rows', at what point, if ever, would the data that I'm looking at be locked?
A colleague of mine stated that when viewing data in this way, the data rows can be locked (I think when he said if you put a cursor on a row and start editing data).
Is this the only time the data can be locked in this context?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
这不是真的。在一个窗口中运行此脚本(并保持其运行):
每 5 秒,它会翻转
Val1
列的值,并在消息选项卡中打印Updated
(假设您设置为“网格中的结果”)。然后,在 SSMS 的另一个实例中,打开
Tx
表并开始编辑其中的单行。观察脚本继续执行更新。It's not true. Run this script in one window (and leave it running):
Every 5 seconds, it flips the value of the
Val1
column, and printsUpdated
in the messages tab (assuming you're set to "results in grid").Then, in another instance of SSMS, open the
Tx
table and start editing the single row in there. Observe that the script continues to perform updates.它可以被锁定。在编辑面板中,尝试插入一行并违反主键约束。您将收到一条错误对话框弹出消息。当您阅读该消息时,该表将被锁定。如果您在未确认消息的情况下离开,该桌子将被无限期锁定。我刚刚通过 SSMS 2008R2 和 SSMS 2012 确认了这一点。
It can be locked. In the Edit Panel, try to insert a row and violate the Primary Key constraint. You will get an error dialog popup message. The table will now be locked while you are reading that message. If you walk away without confirming the message, that table will be locked indefinitely. I just confirmed this with both SSMS 2008R2 and SSMS 2012.
默认情况下,SSMS GUI 编辑器中的数据不会被锁定。
如果您进行更改并尝试保存,您将收到覆盖/丢弃等错误/警告。抱歉,我现在无法测试以查看确切的消息。
The data won't be locked by default in the SSMS GUI editor.
If you make changes and try to save, you'll get errors/warning ato overwrite/discard etc. I can't test right now to see the exact messages, sorry.
事实并非如此。许多人会试图告诉你确实如此,但事实并非如此。经测试并确认。
It does not. Many people will try to tell you it does, however it does not. Tested and confirmed.