Search code examples
sql-serverindexingnon-clustered-index

Clustered and non-clustered index


Is it possible to create a non clustered index which is not unique? What data structure is used to implement non clustered indexes.


Solution

  • Assuming you are talking about SQL Server then simply don't specify UNIQUE when creating the index.

    CREATE /*UNIQUE*/ NONCLUSTERED INDEX IX ON T(C)
    

    As UNIQUE is commented out above this does not enforce uniqueness on the C column. But in fact it will still be made unique behind the scenes by adding the (unique) row locator in to the non clustered index key.

    Regarding data structure both clustered and non clustered indexes are B+ trees.