1) One table can only have one clustered Index but It can have many non clustered index, approximately 250.
This limitation comes from the fact clustered index is used to determines how data is stored physically in table.
2) Another key difference between Clustered Index and Non Clustered Index in database is that many relational database including SQL Server by default creates clustered index on PRIMARY KEY constraint, if there is no clustered index exists in database and a nonclustered index is not specified while declaring PRIMARY KEY constraint.
3) One more difference between them is that, clustered index contains data i..e rows in there leaf node, as Index is represented as BST, while nonclustered index contains pointer to data (address or rows) in there leaf node, which means one more extra step to get the data.
4) We can create clustered index with multiple columns, known as composite index.
Create clustered index for columns which contains unique values, are accessed sequentially, used in range queries and return large result set. Avoid creating clustered index on columns, which are update frequently because that would lead rearrangement of rows on disk level, a potentially slow operation.
Read full article from Difference between Clustered Index and Non Clustered Index in SQL Server - Database Interview Question
This limitation comes from the fact clustered index is used to determines how data is stored physically in table.
2) Another key difference between Clustered Index and Non Clustered Index in database is that many relational database including SQL Server by default creates clustered index on PRIMARY KEY constraint, if there is no clustered index exists in database and a nonclustered index is not specified while declaring PRIMARY KEY constraint.
3) One more difference between them is that, clustered index contains data i..e rows in there leaf node, as Index is represented as BST, while nonclustered index contains pointer to data (address or rows) in there leaf node, which means one more extra step to get the data.
4) We can create clustered index with multiple columns, known as composite index.
Read full article from Difference between Clustered Index and Non Clustered Index in SQL Server - Database Interview Question
No comments:
Post a Comment