Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Documentation on PRIMARY KEY INDEX

Author  Topic 

SamC
White Water Yakist

3467 Posts

Posted - 2004-01-07 : 15:14:10
I've taken it for granted that creating a table with a primary key automatically creates a CLUSTERED INDEX on that primary key.

I just noticed there's no "index" for my PRIMARY KEYs using Query Analyzer object browser.

And I don't see any documentation in BOL about a Primary Key creating a clustered index.

What's the story?

Sam

ehorn
Master Smack Fu Yak Hacker

1632 Posts

Posted - 2004-01-07 : 15:24:26
Check out BOL - PRIMARY KEY Constraints, Creating and Modifying PRIMARY KEY Constraints

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.
create table test ( val int identity(0,1) primary key)
go
sp_helpindex 'test'
go
drop table test
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2004-01-07 : 15:42:47
Sam, the object browser does not show the primary key's index under the indexes. You'll find it under constraints.

Tara
Go to Top of Page

SamC
White Water Yakist

3467 Posts

Posted - 2004-01-07 : 15:57:27
Thanks. I'm glad to know that I wasn't looking in the right places..

Sam
Go to Top of Page
   

- Advertisement -