久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

SQL Server 如何在標識列中生成值?

How does SQL Server generate values in an identity column?(SQL Server 如何在標識列中生成值?)
本文介紹了SQL Server 如何在標識列中生成值?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我的問題是,如果我有兩個并行的批量插入到一個表中,SQL Server 如何創建標識值?

My question is if I have two batch inserts into one table in parallel, how does SQL Server create identity values?

我的意思是,如果在一個會話中我插入多行(Row1-Row2-Row3),同時另一個會話同時插入多行(Row4-Row5-Row6),結果會是這樣嗎?

I mean, if in one session I insert multiple rows (Row1-Row2-Row3) and simultaneously another session inserts multiple rows (Row4-Row5-Row6) at the same time, the result would be like this?

Row1
Row2
Row3
Row4
Row5
Row6

或者類似的東西?

Row1
Row6
Row3
Row5
Row4
Row2

推薦答案

您犯了假定表格中的順序的常見謬誤.表沒有順序.只有結果才有順序,除非指定了明確的 ORDER BY,否則順序是不確定的.

You are making the common fallacy of assuming an order in the table. Tables have no order. Only results have order, which is undetermined unless an explicit ORDER BY is specified.

您可能會問一個不同的問題:在并發插入的情況下,如何分配標識生成的值?答案很簡單:沒關系.如果您對訂單做出任何假設,那么您的代碼就會被破壞.間隙也是如此.即使生成的身份完全隨機,您的應用程序也應該可以運行,如果身份完全隨機,正確編寫的應用程序運行.使用 SCOPE_IDENTITY() 檢索最后一個插入的身份.更好的是,使用 OUTPUT 子句INSERT,它也適用于多行插入.

You may ask a different question: how is the identity generated value assigned in case of concurrent inserts? The answer is simple: it doesn't matter. And if you make any assumption about the order then your code is broken. Same goes for gaps. Your application should work even if the identities generated are completely random, and correctly written application will work if the identity is completely random. Use SCOPE_IDENTITY() to retrieve the last inserted identity. Better still, use the OUTPUT clause of INSERT, it works for multi-row inserts too.

為了記錄:身份是按照操作獲得對日志流.

For the record: the identities are generated in the order on which operations acquire access to the log stream.

這篇關于SQL Server 如何在標識列中生成值?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Modify Existing decimal places info(修改現有小數位信息)
The correlation name #39;CONVERT#39; is specified multiple times(多次指定相關名稱“CONVERT)
T-SQL left join not returning null columns(T-SQL 左連接不返回空列)
remove duplicates from comma or pipeline operator string(從逗號或管道運算符字符串中刪除重復項)
Change an iterative query to a relational set-based query(將迭代查詢更改為基于關系集的查詢)
concatenate a zero onto sql server select value shows 4 digits still and not 5(將零連接到 sql server 選擇值仍然顯示 4 位而不是 5)
主站蜘蛛池模板: 欧美日韩国产在线观看 | 日韩中文字幕2019 | 九九热免费观看 | 国产成人综合一区二区三区 | 久久香蕉网 | 先锋资源吧 | av在线免费观看网站 | 欧美综合在线观看 | 国产精品亚洲成在人线 | 男人天堂999 | 成年人免费网站 | 国产电影一区二区三区爱妃记 | 亚洲国产成人精品在线 | 99资源站 | 成人三级在线观看 | 亚洲一区二区三区在线播放 | 欧美成人h版在线观看 | 欧美黑人体内she精在线观看 | 1000部精品久久久久久久久 | 99福利视频| 黄色片网站国产 | 日韩成人免费av | 精品国产一区二区在线 | 一区二区在线观看av | 国产在线精品免费 | 男女羞羞视频在线观看 | 日本三级电影免费观看 | 91精品国产综合久久香蕉麻豆 | 一区二区国产精品 | 欧美日在线 | 在线免费观看黄色av | 性高湖久久久久久久久3小时 | www.成人.com | 亚洲国产成人av好男人在线观看 | 欧美日韩福利 | 久久一区二区三区四区 | 欧美激情视频一区二区三区免费 | 91久久精品国产91久久 | 8x国产精品视频一区二区 | 久久久久久亚洲精品 | 亚洲欧美中文日韩在线v日本 |