是的,它是 this 的重复 。但我只需要澄清this article作者:Pinal Dave,内容如下:
Scenario 4: Primary Key defaults to Clustered Index with other index defaults to Non-clustered index
In this case we will create two indexes on the both the tables but we will not specify the type of the index on the columns. When we check the results we will notice that Primary Key is automatically defaulted to Clustered Index and another column as a Non-clustered index.
-- Case 4 Primary Key and Defaults USE TempDB GO -- Create table CREATE TABLE TestTable (ID INT NOT NULL PRIMARY KEY, Col1 INT NOT NULL UNIQUE) GO -- Check Indexes SELECT OBJECT_NAME(OBJECT_ID) TableObject, [name] IndexName, [Type_Desc] FROM sys.indexes WHERE OBJECT_NAME(OBJECT_ID) = 'TestTable' GO -- Clean up DROP TABLE TestTable GO
最佳答案
唯一自动创建的索引:
主键上的聚集索引(除非您另外指定 - 如果您将主键定义为非聚集,则将创建非聚集索引)
将
UNIQUE CONSTRAINT
应用于一列(或一组列)时的唯一非聚集索引
关于sql - SQL Server默认创建非聚集索引,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16746875/