Results 1 to 8 of 8
  1. #1
    Join Date
    Jul 2002
    Location
    Island of Dots
    Posts
    316

    Unanswered: Any need to create an Index for a PK field?

    Are Primary Key fields automatically indexed, or do you have to create a seperate index for a PK in order for it to be indexed? I'm using SQL Server 2005.

  2. #2
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    That's not really hard to find out

    sp_help table
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

  3. #3
    Join Date
    Jul 2002
    Location
    Island of Dots
    Posts
    316
    Thanks. So the answer is no, you don't have to create a seperate index for a PK.

  4. #4
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    No - the answer is yes. SQL Server (and pretty well all RDBMSs) enforce PKs and unique constraints with indexes.
    Testimonial:
    pootle flump
    ur codings are working excelent.

  5. #5
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    no, no, no!! the answer is no, you do not have to create a separate index for a PK
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  6. #6
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Oh no! I misread! I swear I misread!
    Testimonial:
    pootle flump
    ur codings are working excelent.

  7. #7
    Join Date
    May 2004
    Location
    Seattle
    Posts
    1,313
    you are both wrong.

    >>Are Primary Key fields automatically indexed?

    yes.

    >>do you have to create a seperate index for a PK in order for it to be indexed?

    no.


  8. #8
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    well, the original question was X or Y, and since jez has pointed out that the answers were yes and no respectively, this resolves to YES or NO, which resolves to NO!!

    (note: ANDs and ORs do not work the same with YES and NO as they do with TRUE and FALSE -- ask any guy who has every been married, if your choice is YES or NO, the answer is NO)
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •