5 pts.
 Indexing
Whatis the difference between a Clustered Index and a Non-Clustered Index

Software/Hardware used:
ASKED: July 30, 2008  5:27 PM
UPDATED: July 31, 2008  1:57 AM

Answer Wiki:
Since you didn't specify what database platform you are using, I'm coming from the SQL Server world. A clustered index contains the entire record, while a non-clustered index contains only the columns specified in the CREATE INDEX command. In order version of SQL Server the clustered index also controlled the physical order of the data within the table. This is no longer the case (and is documented in <a href="http://msdn.microsoft.com/en-us/library/aa196197.aspx">Books OnLine</a>). The clustered index must be created within the same filegroup as the table, while nonclustered indexes can be created in any filegroup. You can only have one clustered index per table, while you can have hundreds of nonclustered indexes per table. When you do a look up against a clustered index, and you need to go to the base table to get the row, the clustered index contains a pointer to the physical table and the location of the data. When you query a nonclustered index, that nonclustered index contains a pointer to the location within the clustered index which contains the data you are looking for, which then references the physical table. When using indexes on a table without a clustered index the nonclustered indexes contain references back to the physical table. You can read up more about the physical structure of the <a href="http://msdn.microsoft.com/en-us/library/ms177443.aspx">clustered index</a> and the <a href="http://msdn.microsoft.com/en-us/library/ms177484.aspx">nonclustered index </a>on Microsoft's site.
Last Wiki Answer Submitted:  July 31, 2008  1:57 am  by  Denny Cherry   64,520 pts.
All Answer Wiki Contributors:  Denny Cherry   64,520 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

Check out my SQL Server blog “SQL Server with Mr Denny” for more SQL Server information.

 64,520 pts.