Is primary key always indexed in sql server?

You can create a clustered index in a column other than the primary key column if you specify a non-clustered primary key constraint. http://msdn.microsoft.com/en-us/library/ms186342.aspx

So, the above said to me: I can create a clustered index in columns other than the primary key.

I think this also means that the primary key must be either a non-clustered primary key or a clustered key. Is it possible that the primary key is not indexed?

What else:

When you create a UNIQUE constraint, a unique non-clustered index is created to force the default UNIQUE constraint. You can specify a unique clustered index if the clustered index in the table does not already exist.

Does this mean that a unique constraint should create a clustered index or a non-clustered index?

+5
source share
2 answers

Is it possible that the primary key is not indexed?

No, it is not.

For protection PRIMARY KEY, some kind of index is required, otherwise it would require scanning the entire table for each insert (to ensure uniqueness).

From docs :

PRIMARY KEY. , PRIMARY KEY.


, ?

, .


PRIMARY KEY UNIQUE , . , , ALTER TABLE ADD CONSTRAINT UNIQUE CREATE UNIQUE INDEX .

- - , SQL Server 2155 , B-Tree .

+12

: ,

SQL Server . () . - . .

http://www.sqlfiddle.com/#!6/972f0/1
+1

All Articles