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.
| Author |
Topic |
|
KabirPatel
Yak Posting Veteran
54 Posts |
Posted - 2007-04-04 : 05:03:19
|
| Hi,I have a basic question to ask.If I create a Primary Key constraint on a table, is this automatically a clustered index?i.e. If I do the following:ALTER TABLE [myTable]ADD CONSTRAINT PK_ID PRIMARY KEY (myID)GOshould I also create a clustered index?Thanks,Kabir |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-04-04 : 05:10:32
|
No.quote: Books Online
PRIMARY KEY Is a constraint that enforces entity integrity for a specified column or columns through a unique index. Only one PRIMARY KEY constraint can be created per table.UNIQUE Is a constraint that provides entity integrity for a specified column or columns through a unique index. A table can have multiple UNIQUE constraints.CLUSTERED | NONCLUSTERED Indicate that a clustered or a nonclustered index is created for the PRIMARY KEY or UNIQUE constraint. PRIMARY KEY constraints default to CLUSTERED, and UNIQUE constraints default to NONCLUSTERED.In a CREATE TABLE statement, CLUSTERED can be specified for only one constraint. If CLUSTERED is specified for a UNIQUE constraint and a PRIMARY KEY constraint is also specified, the PRIMARY KEY defaults to NONCLUSTERED.
Peter LarssonHelsingborg, Sweden |
 |
|
|
|
|
|