Default Key - Clustered or Non?

  • Hi All,

    If I ran the following statement what type of primary key would it create and can this be altered in the settings?

    CREATE TABLE EMP_DETAILS (EMPLOYEE_ID INT PRIMARY KEY, EMPLOYEE_NAME VARCHAR(25),

    DOJ DATETIME, DEPT_ID INT, SALARY INT);

    Thanks.

  • clustered

    you can check on the index (+) thingy on the table in QA


    Everything you can imagine is real.

  • It will create a unique clustered non-null index. A primary key must be non-null and must be unique, however, you can add the keyword nonclustered if you don't want it clustered. Like so:

    CREATE TABLE EMP_DETAILS (EMPLOYEE_ID INT nonclustered PRIMARY KEY,  EMPLOYEE_NAME VARCHAR(25),

    DOJ DATETIME, DEPT_ID INT, SALARY INT);


    My blog: SQL Soldier[/url]
    SQL Server Best Practices:
    SQL Server Best Practices
    Twitter: @SQLSoldier
    My book: Pro SQL Server 2008 Mirroring[/url]
    Microsoft Certified Master: SQL Server, Data Platform MVP
    Database Engineer at BlueMountain Capital Management[/url]

Viewing 3 posts - 1 through 2 (of 2 total)

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