Index & PK

  • When we create Primary key on a table by default it will create clustered index automatically. If I don't want create any indexes on that table but just I want to create primary key on that table how can we do?

    How the primary key makes the table unique but how unique key makes column unique in the table. Please give me good example to understand this..

  • You can't. Any primary key or unique constraint is enforced by an index. You can choose a non clustered index for the primary key if you prefer.

    John

  • You can create a primary key and use the word NONCLUSTERED to force it to not be a clustered index.

    But, other than that, you've got the answer. Unique constraints create indexes.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

  • Thank you

  • ramana3327 (12/20/2013)


    When we create Primary key on a table by default it will create clustered index automatically. If I don't want create any indexes on that table but just I want to create primary key on that table how can we do?

    How the primary key makes the table unique but how unique key makes column unique in the table. Please give me good example to understand this..

    Please give me good example to understand why you want a table with no indexes?

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply