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

SQL SERVER:唯一約束說明

SQL SERVER: Unique Constraint Explanation(SQL SERVER:唯一約束說明)
本文介紹了SQL SERVER:唯一約束說明的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

限時送ChatGPT賬號..

有人可以簡化向列添加唯一約束的解釋嗎?創(chuàng)建鍵索引時,SQL SERVER 是復(fù)制行中的所有信息并將其添加到索引中,還是僅將列中的數(shù)據(jù)添加到應(yīng)用了 UNIQUE CONSTRAINT 的數(shù)據(jù)中?

Could someone simplify the explanation of adding a UNIQUE CONSTRAINT to a column please. When creating the key index does SQL SERVER copy ALL of the information in the row and add it to the index or just the data in the column with the applied UNIQUE CONSTRAINT?

我希望我能正確解釋.
任何幫助將不勝感激.
李.

I hope I explained that properly.
Any help will be greatly appreciated.
Lee.

編輯**

好吧,我想我明白了嗎?

Ok i think i get it?

CREATE TABLE dbo.test 
    (
    Id int NOT NULL, 
    Name char(10) NOT NULL UNIQUE
    );

INSERT INTO dbo.test (id, name) VALUES (1, 'Lee')
INSERT INTO dbo.test (id, name) VALUES (2, 'Paul')
INSERT INTO dbo.test (id, name) VALUES (3, 'Adam')
INSERT INTO dbo.test (id, name) VALUES (4, 'Henry')

在聚集索引中,整個表將像這樣排序

In a clustered index the whole table would be sorted like

3, Adam
4, Henry
1, Lee
2, Paul

那么,每增加一個 INSERT,服務(wù)器就必須根據(jù) name 列對整個表重新排序?

So with each additional INSERT the server would have to re-sort the entire table based on the name column?

在非聚集索引中還有另一個表"存儲排序?

In a nonclustered index there is another "table" that stores the sort?

推薦答案

UNIQUE CONSTRAINT 將與 UNIQUE INDEX 一樣工作.有兩種方式:

UNIQUE CONSTRAINT will work just as UNIQUE INDEX. There are 2 ways:

  • 使用聚集索引,行以與索引相同的順序物理存儲在磁盤上.(因此,只有一個聚集索引是可能的)

  • With a clustered index the rows are stored physically on the disk in the same order as the index. (hence, only one clustered index is possible)

對于非聚集索引,還有一個指向物理行的指針的第二個列表.您可以擁有多個非聚集索引,盡管每個新索引都會增加寫入新記錄所需的時間.

With a non clustered index there is a second list that has pointers to the physical rows. You can have many non clustered indexes, although each new index will increase the time it takes to write new records.

如果您同時擁有聚集索引和非聚集索引,那么非聚集索引將指向聚集索引列.

If you have both clustered and non clustered index, then non clustered index will point to the clustered index column.

這個'SO' 回答會幫助你理解得更清楚一些.

THIS 'SO' answer will help you understand it a bit clear.

默認(rèn)情況下,唯一約束和唯一索引將創(chuàng)建一個非如果您沒有指定任何不同的聚集索引(并且 PK 將通過如果沒有沖突的聚集索引,則默認(rèn)創(chuàng)建為 CLUSTERED存在)但您可以為任何顯式指定 CLUSTERED/NONCLUSTERED其中.

By default the unique constraint and Unique index will create a non clustered index if you don't specify any different (and the PK will by default be created as CLUSTERED if no conflicting clustered index exists) but you can explicitly specify CLUSTERED/NONCLUSTERED for any of them.

這篇關(guān)于SQL SERVER:唯一約束說明的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

相關(guān)文檔推薦

What SQL Server Datatype Should I Use To Store A Byte[](我應(yīng)該使用什么 SQL Server 數(shù)據(jù)類型來存儲字節(jié) [])
Interpreting type codes in sys.objects in SQL Server(解釋 SQL Server 中 sys.objects 中的類型代碼)
Typeorm Does not return all data(Typeorm 不返回所有數(shù)據(jù))
Typeorm .loadRelationCountAndMap returns zeros(Typeorm .loadRelationCountAndMap 返回零)
MS SQL: Should ISDATE() Return quot;1quot; when Cannot Cast as Date?(MS SQL:ISDATE() 是否應(yīng)該返回“1?什么時候不能投射為日期?)
Converting the name of a day to its integer representation(將一天的名稱轉(zhuǎn)換為其整數(shù)表示)
主站蜘蛛池模板: 日韩在线视频免费 | 欧美日韩国产在线观看 | 午夜精品在线观看 | 免费观看av网站 | aaaaa毛片| 毛片视频免费观看 | 中文在线一区 | 亚洲国产二区 | 中文字幕www | 国产伦精品一区二区三区四区 | 久久精品区 | 欧美日韩在线一区二区三区 | 欧美亚洲在线观看 | h片免费看 | 黄色片网站免费 | 成人午夜网 | www.日日夜夜 | www激情 | 日日夜夜狠狠干 | 亚洲免费福利视频 | 三年中文在线观看免费大全中国 | 午夜视频一区二区三区 | 国产1区2区| 国产伦精品一区二区三区在线 | 日本一区二区不卡视频 | 99视频+国产日韩欧美 | 欧美一区不卡 | 日韩欧美在线一区 | 美女久久久 | 久艹视频在线观看 | 亚洲在线免费视频 | 欧美成人精品欧美一级私黄 | 亚洲国产精品久久久 | 国产又爽又黄免费视频 | 黄色成年人网站 | 人人草人人 | 视频在线观看一区 | 欧美三级韩国三级日本三斤在线观看 | 中文字幕亚洲综合 | 日日撸夜夜操 | 电家庭影院午夜 |