Clustered Index
Create Clustered index [cluster-name]
on tablename(ColumnName)
Non Clustered Index
How to create a Non-Cluster index- cluster Index determines the physical order of data in a table
- Primary key automatically Create a Cluster Index
- A table can only have 1 cluster index, but 1 cluster index can have multiple column
- Int and nvarchar both can have clustered index but nvarchar should not have max
- Cluster indexes are faster than non Clustered Index because both index and data are on same table
Create Clustered index [cluster-name]
on tablename(ColumnName)
Non Clustered Index
- In a Non-Clustered Index the index is stored seperately
- Just like a book the index is stored at the first page and data is on the other page
- A table can contain more than 1 non clustered index
- non Cluster indexes are slower than Clustered Index because index and data are on different table
- Becuase non clustered index are stored in a seperate table they require additional disk space
Create nonclustered index [cluster-name]
on tablename(ColumnName)
How to check if a tabel has index or not
Execute sp_helpindex [table-name]
I hope it was informative for you and I would like to Thank you for reading.
No comments:
Post a Comment