|
|
|
Say Hey Kid
      
Group: General Forum Members
Last Login: Today @ 11:49 AM
Points: 662,
Visits: 699
|
|
L' Eomot Inversé (6/14/2012) Most of those errors were the same wrong answer, there appears to a widely distributed myth that any primary index is clustered unless it is declared as unclustered. I knew that such a myth existed, but I thought it was so often debunked that only a small proportion of people still believed it. I don't think I'd call it a myth so much as an incomplete understanding of index creation pertaining to primary keys. Since the default is, in fact, a clustered index, many may never have considered the possibility that there was any other option. I know I hadn't. But I don't think I would describe my situation as tantamount to having mindlessly bought into a long-debunked ghost story that of course nobody in the modern age believes anymore.
ron
----- a haiku...
NULL is not zero NULL is not an empty string NULL is the unknown
|
|
|
|
|
SSC Veteran
      
Group: General Forum Members
Last Login: Friday, November 09, 2012 7:25 AM
Points: 298,
Visits: 107
|
|
I would second that, as the first BOL quote says, a primary key IS created as clustered by default. There's just the "unless there's an additional unique constraint declared as clustered" line after that as well. Since we certainly all know you have to declare the clustered option before the comma that's how I (and the other 66% of responsers answering just "Clustered") tripped up.
Good question that proves you need to always pay FULL attention to the QotD question and answers!
|
|
|
|
|
SSChasing Mays
      
Group: General Forum Members
Last Login: Today @ 10:46 AM
Points: 650,
Visits: 1,537
|
|
ronmoses (6/14/2012)
L' Eomot Inversé (6/14/2012) Most of those errors were the same wrong answer, there appears to a widely distributed myth that any primary index is clustered unless it is declared as unclustered. I knew that such a myth existed, but I thought it was so often debunked that only a small proportion of people still believed it.I don't think I'd call it a myth so much as an incomplete understanding of index creation pertaining to primary keys. Since the default is, in fact, a clustered index, many may never have considered the possibility that there was any other option. I know I hadn't. But I don't think I would describe my situation as tantamount to having mindlessly bought into a long-debunked ghost story that of course nobody in the modern age believes anymore. ron
This.
The opinions expressed herein are strictly personal and do not necessarily reflect the views or policies of my employer.
|
|
|
|
|
SSC Eights!
      
Group: General Forum Members
Last Login: Today @ 12:17 PM
Points: 856,
Visits: 1,279
|
|
Excellent question, thanks Hugo! There always seems to be a lot of confusion around this.
|
|
|
|
|
Right there with Babe
      
Group: General Forum Members
Last Login: Today @ 5:56 AM
Points: 732,
Visits: 1,231
|
|
ronmoses (6/14/2012)
L' Eomot Inversé (6/14/2012) Most of those errors were the same wrong answer, there appears to a widely distributed myth that any primary index is clustered unless it is declared as unclustered. I knew that such a myth existed, but I thought it was so often debunked that only a small proportion of people still believed it.I don't think I'd call it a myth so much as an incomplete understanding of index creation pertaining to primary keys. Since the default is, in fact, a clustered index, many may never have considered the possibility that there was any other option. I know I hadn't. But I don't think I would describe my situation as tantamount to having mindlessly bought into a long-debunked ghost story that of course nobody in the modern age believes anymore. ron
If I may. I answered Clustered. The reason is that I was trying to divine the intent of the author. Is the intent to test your Index DEFAULT (as the name of the QotD implies), in which case the answer CLUSTERED is correct. The Default for PRIMARY KEY is CLUSTERED. In this case the Intent was to see if you knew the second half, which is... if CLUSTERED explicitly listed later in the Table Definition, does the PRIMARY KEY become CLUSTERED or NONCLUSTERED?
I submit that 86% are answering question 1, while the QotD is on Question 2. If it is the intent to test Question 2, then the question is poorly worded.
|
|
|
|
|
SSChampion
        
Group: General Forum Members
Last Login: Today @ 3:07 PM
Points: 10,613,
Visits: 11,959
|
|
|
|
|
|
SSCrazy Eights
        
Group: General Forum Members
Last Login: Yesterday @ 6:30 AM
Points: 9,410,
Visits: 6,495
|
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Today @ 12:22 PM
Points: 1,385,
Visits: 295
|
|
Awesome question. Instinct was to pull the trigger on clustered, but then I made sure to read all the answers. So I tried to create the table and also add a column with a unique clustered constraint on it, and viola, the KeyColumn index changed to a nonclustered.
Learned something here, which is the point.
|
|
|
|
|
Hall of Fame
       
Group: General Forum Members
Last Login: Today @ 11:47 PM
Points: 3,250,
Visits: 65,578
|
|
venoym (6/14/2012)
If I may. I answered Clustered. The reason is that I was trying to divine the intent of the author. Is the intent to test your Index DEFAULT (as the name of the QotD implies), in which case the answer CLUSTERED is correct. The Default for PRIMARY KEY is CLUSTERED. In this case the Intent was to see if you knew the second half, which is... if CLUSTERED explicitly listed later in the Table Definition, does the PRIMARY KEY become CLUSTERED or NONCLUSTERED?
I submit that 86% are answering question 1, while the QotD is on Question 2. If it is the intent to test Question 2, then the question is poorly worded.
I certainly answered as though this were Question #1. Without being sure which answer the questioner was aiming at, it's perfectly conceivable that some portion of the 86% of us were all answering Question #1.
It's not as though I'm not aware of the fact that you can make the clustered index be something other than the Primary Key, just that when I want that, I generally create the table as a heap, with an ALTER TABLE ADD CONSTRAINT to add the Clustered index, followed by declaring the PK after that. It may not be the quickest way to do things, but when I'm looking at my code later, I can be sure I remember what my intentions were.
--Mark Tassin MCITP - SQL Server DBA Proud member of the Anti-RBAR alliance. For help with Performance click this link For tips on how to post your problems
|
|
|
|
|
Hall of Fame
       
Group: General Forum Members
Last Login: Today @ 11:47 PM
Points: 3,250,
Visits: 65,578
|
|
|
|
|