.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Articles >> DataBase >> Post New Resource Bookmark and Share   

 Subscribe to Articles

Indexes in SQL

Posted By:Athira Sreejith       Posted Date: December 31, 2008    Points: 15    Category: DataBase    URL: http://www.dotnetspark.com  
 

Indexes in SQL server are similar to the indexes in Books.
They help SQL server retrieve the data quickly.

There are clustered and nonmclustered indexes.

A clustered indexes is a special type of index that records the way in which records in the table
are physically stored.Therefore , table can have only one clustered index.The leaf nodes of a clustered index contain the data pages.

A nonClustered index is a special type of index in which the logical order of the index
does not match the physical stored order of the rows on disk.The leaf node of a non clustered index dows not consist of the data pages .Instead the leaf nodes contain index rows.


The syntax for creating indexes
CREATE INDEX idxModel
ON Product (Model)

 

Let's assume that we have the following table,


TABLE Customer
(First_Name char(50),
Last_Name char(50),
Address char(50),
City char(50),
Country char(25),
Birth_Date date)

and we want to create an index on the column Last_Name, we would type in,


CREATE INDEX IDX_CUSTOMER_LAST_NAME
on CUSTOMER (Last_Name)
[/COED]
If we want to create an index on both City and Country, we would type in,

CREATE INDEX IDX_CUSTOMER_LOCATION
on CUSTOMER (City, Country)

 

 Subscribe to Articles

     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More Articles on C#, ASP.Net, Vb.Net, SQL Server and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend