Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can we create clustered index with include columns

Can we create a clustered index with include columns in Microsoft SQL Server (T-SQL)?

If yes then how does it work internally?

As per my understanding the leaf level of the clustered index are the actual data pages itself, and it stores entire row include with the key column (on which index is created).

like image 227
ram Avatar asked Oct 17 '22 08:10

ram


1 Answers

You cannot specify included columns in a clustered columnstore index. From the manual:

Nonkey columns can only be defined on nonclustered indexes

The reason for this is that when you apply a clustered columnstore index to a table, SQL Server changes the physical storage of the table to columns. As such, all columns are included in the clustered columnstore index.

like image 91
e_i_pi Avatar answered Oct 20 '22 05:10

e_i_pi