Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Are Primary Key columns indexed by default????

Status
Not open for further replies.

stiej

Technical User
Jan 20, 2003
142
GB
Hello,

Is a primary key (apart from being unique) also an index? Or is it possible to have unindexed primary keys?

thanks!
 
BOL
Code:
SQL Server automatically creates a unique index to enforce the uniqueness requirement of the PRIMARY KEY constraint. If a clustered index does not already exist on the table, or a nonclustered index is not explicitly specified, a unique, clustered index is created to enforce the PRIMARY KEY constraint.
 
Primary keys are indexed by default. In fact, the primary key is implemented through a unique index and is usually clustered. Clustered Indexes are better/faster than 'regular' indexes, but you can only have 1 clustered index per table.

>> Or is it possible to have unindexed primary keys?

It is not possible to have a primary key without having an index. Is this a problem for you?

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
thanks guys. i was not actually wanting to make a non indexed primary key, i was just didnt know whether ornot pk's are indexed. thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top