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 |
|
suneil23
Starting Member
4 Posts |
Posted - 2006-07-03 : 01:31:24
|
| please tell me what is the point in using this "constraint PK_Customers PRIMARY KEY CLUSTERED CustomerID)"in the below mentioned querycreate table customers(customerID int not null,customername char(10) not null,country char(20) null,constraint PK_Customers PRIMARY KEY CLUSTERED CustomerID));insert into customers values(1001,'Ram','India');insert into customers values(1002,'Sam','USA');insert into customers values(1003,'Tom','UK');insert into customers values(1004,'Pam','Australia');insert into customers values(1005,'Van','USA');insert into customers values(1006,'Mam','UK');insert into customers values(1007,'Kim','USA');insert into customers values(1008,'Kin','China');insert into customers values(1009,'Pin','China');insert into customers values(1010,'Min','Japan');select *from customers; |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-07-03 : 01:59:44
|
| To make CustomerID as primary key with constraint name PK_Customers Read about Create table in sql server help file for more informationMadhivananFailing to plan is Planning to fail |
 |
|
|
jen
Master Smack Fu Yak Hacker
4110 Posts |
Posted - 2006-07-03 : 02:53:53
|
| no benefit, coz it'll still do a scan on the tableshow the execution plan when you run the query and you'll get the info you need--------------------keeping it simple... |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-07-03 : 03:09:21
|
| If you want to select all rows and still want to make use of Index then use where clause select *from customers where customerID>0provided that it is always more than 0MadhivananFailing to plan is Planning to fail |
 |
|
|
mr_mist
Grunnio
1870 Posts |
Posted - 2006-07-03 : 04:10:45
|
| It will do a scan with that SELECT * FROM yourtable, but one benefit is that the PRIMARY KEY constraint will enforce integrity on the customer ID, meaning that you won't get duplicates in your database.-------Moo. :) |
 |
|
|
|
|
|
|
|