Unlike from my previous example of index on the back of an Atlas, which normally has one index, a table may have multiple indexes. These indexes can be defined on one or more columns of the tables. The two major types of indexes in SQL Server are Clustered and Non-clustered Indexes.
Clustered Indexes: A clustered when defined on a column of a table, the data of the table in the data pages are sorted in order of the column on which index is defined. This column is referred as an Index Key. Since the data is sorted physically on the disk, the leaf page of the index pages are the data pages of the table.
Inserting a new row in a table with clustered index defined, SQL Server ensures that the row is placed in the correct physical location in key sequence order. Structure of the Clustered Index is as given below:
Non-clustered index structure is depicted as:
Both the clustered and non-clustered indexes can be defined on one or more columns of a table, to serve the frequent database queries. However there can be only one clustered index defined on a table while there can be 249 non-clustered indexes created on a table.
Any idea y only 249 non clusterd indexes can be kept on a table?? y not 250 y not 248
ReplyDeleteEach nonclustered index created for a table or view has a row in sysindexes.
ReplyDeleteThe values for indid in the rows for each nonclustered index range from 2 through 250. and so there can only be 249 non clustered indexes created on a table.
Also if practically that many indexes are defined on a table, the cost of maintaining indexes will be far high than the table.