You are on page 1of 2

lnuLxLS

8elaLlonal daLabases llke SCL Server use lndexes Lo flnd daLa qulckly when a query ls
processed CreaLlng and removlng lndexes from a daLabase schema wlll rarely resulL ln
changes Lo an appllcaLlons code lndexes operaLe behlnd Lhe scenes ln supporL of Lhe
daLabase englne Powever creaLlng Lhe proper lndex can drasLlcally lncrease Lhe
performance of an appllcaLlon
Conslder Lhe followlng query on Lhe roducLs Lable
SLLLC1 roductId roductName Un|tr|ce
IkCM products
WnLkL (un|t_pr|ce 12S) AND (un|t_pr|ce 14)



now lmaglne lf we creaLed an lndex [usL llke a book lndex on Lhe daLa ln Lhe unlLrlce column Lach
lndex enLry would conLaln a copy of Lhe unlLrlce value for a row and a reference ([usL llke a page
number) Lo Lhe row where Lhe value orlglnaLed SCL wlll sorL Lhese lndex enLrles lnLo ascendlng
order 1he lndex wlll allow Lhe daLabase Lo qulckly narrow ln on Lhe Lhree rows Lo saLlsfy Lhe query
and avold scannlng every row ln Lhe Lable

We can creaLe Lhe same lndex uslng Lhe followlng SCL SL8vL8
C8LA1L lnuLx lux_unlLrlce Cn producLs (unlLrlce)
To veriIy that the index is created, use the Iollowing stored procedure to see a list oI all
indexes on the Products table:
LxLC sp_helplndex CusLomers
CLuS1L8Lu unCLuS1L8Lu lnuLx
CLuS1L8Lu
CreaLes an lndex ln whlch Lhe loglcal order of Lhe key values deLermlnes Lhe physlcal order
of Lhe correspondlng rows ln a Lable 1he boLLom or leaf level of Lhe clusLered lndex
conLalns Lhe acLual daLa rows of Lhe Lable A Lable or vlew ls allowed one clusLered lndex aL a
Llme
nCnCLuS1L8Lu
CreaLes an lndex LhaL speclfles Lhe loglcal orderlng of a Lable WlLh a nonclusLered lndex Lhe
physlcal order of Lhe daLa rows ls lndependenL of Lhelr lndexed order

S?n1Ax
C8LA1L unlCuLCLuS1L8Lu | nCnCLuS1L8Lu lnuLx lndex_name
Cn ob[ecL (column ASC | uLSC n)
u8C lnuLx

1he u8C lnuLx sLaLemenL deleLes lndexes from Lhe currenL SCL Server daLabase
u8C lnuLx lndex_name Cn schema_name Lable_name

You might also like