Wednesday, May 4, 2011

How many types of Indexes ?

What is Index we know How many types of  indexes in sql server ?

--CLUSTERED INDEX
--NON CLUSTERED INDEX 
--UNIQUE INDEX

CLUSTERED INDEX :

Only one clustered index is allowed per table the order of values in  a table order of values in index is also same when cluster index is created on table data is arranged in ascending order cluster index will occupy 5% percent of the table

syntax:
CREATE CLUSTERED INDEX INDEXNAME ON TABLENAME(COLUMNNAME)

NONCLUSTERED INDEX :

It is the default index created by the server the physical order of the data in the table is different from the order of the values in index, max no. of non clustered indexed allowed for table 249(2005)/
999(2008)
CREATE NONCLUSTERED INDEX INDEXNAME ON TABLENAME(COLUMNNAMES)

CREATE NONCLUSTERED INDEX INDEXNAME ON TABLENAME(COL1,COL2)


UNIQUE INDEX :
An index with unique constraint. it will not allow duplicate values
CREATE UNIQUE INDEX INDEXNAME ON TABLENAME(COLUMN)
COMPOSITE INDEX  :  if we create unique index more than one column it will called composite index

No comments:

Post a Comment