Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Performance Primary Keys creation Expand / Collapse
Author
Message
Posted Wednesday, May 1, 2013 2:53 PM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Tuesday, November 18, 2014 4:13 PM
Points: 219, Visits: 716
Hi,

I am trying to figure out if there is a difference in performance between these two statements to create a primary key:

ALTER TABLE Customer ADD PRIMARY KEY CLUSTERED ([iCustID] ASC)

ALTER TABLE Customer ADD CONSTRAINT PK_ Customer PRIMARY KEY CLUSTERED (iCustID ASC)

Is it the same thing?
Thanks



Post #1448621
Posted Wednesday, May 1, 2013 2:59 PM


SSC-Forever

SSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-Forever

Group: General Forum Members
Last Login: Today @ 7:43 AM
Points: 40,438, Visits: 36,894
Same thing. The only difference is in one you specify the PK name, in the other you get an automatically generated name. In all other aspects those two statements are identical.


Gail Shaw
Microsoft Certified Master: SQL Server 2008, MVP
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass

Post #1448624
Posted Thursday, May 2, 2013 6:36 AM


SSCarpal Tunnel

SSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal Tunnel

Group: General Forum Members
Last Login: Today @ 7:09 AM
Points: 4,439, Visits: 6,346
GilaMonster (5/1/2013)
Same thing. The only difference is in one you specify the PK name, in the other you get an automatically generated name. In all other aspects those two statements are identical.


As a matter of preference I always encourage architects/devs to ALWAYS explicitly name anything/everything they create that is namable. This will prevent auto-generated stuff from showing up as a difference if/when you compare databases (say across dev/test/prod systems). It also lets you know intelligently what the object really is by a good naming scheme.


Best,

Kevin G. Boles
SQL Server Consultant
SQL MVP 2007-2012
TheSQLGuru at GMail
Post #1448783
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse