SlideShare a Scribd company logo
1 of 2
Indexes: 
Index is used for faster access of data from table and will show records in the table in ascending 
order or descending order. Index in SQLSERVER will works automaticall.there is no need to open or 
to close and index. 
Types of indexes: 
1. Clustered index 
2. non-clustered index 
Clustered index: 
1. A table can contain only one clustered index. If table contains primary key column then on that 
column clustered index will work. 
2. This index will change the physical order of records in the table based on indexed column. 
Non-clustered index: 
1. A table can contain 249 non-clustered indexes. 
2. If table contains uni-constraints then on that column non clustered index will work.it will not 
change the physical order of records in the table but with the help of reference (book index & index 
key) of the table. 
3. it will show the records in ascending or descending order. 
SYNTAX: 
CREATE[UNIQUE][CLUSTERED/NON-CLUSTERED] 
INDEX<INDEX_NAME> 
ON<TABLE_NAME>(<COLUMN_NAME>[DESC]) 
TO DELETE INDEX: 
DROP INDEX<TABLE_NAME><INDEX_NAME> 
CLUSTERED INDEX: 
CREATE CLUSTEREDINDEX MYINDEX1 
ON EMPLOYEE(ENO) 
SELECT * FROM EMPLOYEE 
(ENO WILL BE IN ASCENDING ORDER)
DROP INDEX EMPLOYEE.MYINDEX1 
SELECT * FROM EMPLOYEE 
(ENO WILL BE IN ASCENDING ORDER) 
NON-CLUSTERED INDEX: 
CREATE NONCLUSTEREDINDEX MYINDEX2 
ON EMPLIST (ENO) 
INCLUDE(ENAME,SAL) 
SELECT * FROM EMPLIST 
(ENO WILL BE IN ASCENDING ORDER) 
DROP INDEX EMPLIST.MYINDEX2 
SELECTR * FROM EMPLIST 
(ENO WILL BE IN PREVIOUS ORDER) 
MULTIPLE NONCLUSTERED INDEX: 
CREATE NONCLUSTEREDINDEX MYINDEX3 
ON EMPLOYEE(ENO) 
INCLUDE(ENAME,SAL) 
CREATE NONCLUSTEREDINDEX MYINDEX4 
ON EMPLOYEE(SAL) 
INCLUDE(ENAME,SAL) 
SELECT * FROM EMPLOYEE WHERE ENO>100 
SELECT * FROM EMPLOYEE WHERE SAL>1000 
NOTE: 
If The Table Contains Multiple Nonclustered Indexes Then Two Conditions Should Be Satisfied 
1. Select Statement With Where Clause 
2. Indexed Column In Where Clause

More Related Content

What's hot

SQL Introduction to displaying data from multiple tables
SQL Introduction to displaying data from multiple tables  SQL Introduction to displaying data from multiple tables
SQL Introduction to displaying data from multiple tables Vibrant Technologies & Computers
 
CS 542 Database Index Structures
CS 542 Database Index StructuresCS 542 Database Index Structures
CS 542 Database Index StructuresJ Singh
 
Creating, altering and dropping tables
Creating, altering and dropping tablesCreating, altering and dropping tables
Creating, altering and dropping tablespunu_82
 
Sql Keywords - You Need to Use
Sql Keywords - You Need to UseSql Keywords - You Need to Use
Sql Keywords - You Need to UseAmrit Tiwari
 
Oracle sql joins
Oracle sql joinsOracle sql joins
Oracle sql joinsredro
 
VLOOKUP Function - Marelen Talavera - Vivacious Analytic
VLOOKUP Function - Marelen Talavera - Vivacious AnalyticVLOOKUP Function - Marelen Talavera - Vivacious Analytic
VLOOKUP Function - Marelen Talavera - Vivacious AnalyticMaria Elena Acdol-Talavera
 
Vlookup - an introduction
Vlookup - an introductionVlookup - an introduction
Vlookup - an introductionvvmenon22
 
PHP mysql Mysql joins
PHP mysql  Mysql joinsPHP mysql  Mysql joins
PHP mysql Mysql joinsMudasir Syed
 
Sql select statement
Sql select statementSql select statement
Sql select statementVivek Singh
 
Web app development_my_sql_09
Web app development_my_sql_09Web app development_my_sql_09
Web app development_my_sql_09Hassen Poreya
 
Guide To Mastering The MySQL Query Execution Plan
Guide To Mastering The MySQL Query Execution PlanGuide To Mastering The MySQL Query Execution Plan
Guide To Mastering The MySQL Query Execution PlanOptimiz DBA
 
How to use Hlookup find an exact match
How to use Hlookup find an exact match How to use Hlookup find an exact match
How to use Hlookup find an exact match Excel Advise
 

What's hot (18)

Formulas Cheat Sheet
Formulas Cheat SheetFormulas Cheat Sheet
Formulas Cheat Sheet
 
SQL Introduction to displaying data from multiple tables
SQL Introduction to displaying data from multiple tables  SQL Introduction to displaying data from multiple tables
SQL Introduction to displaying data from multiple tables
 
CS 542 Database Index Structures
CS 542 Database Index StructuresCS 542 Database Index Structures
CS 542 Database Index Structures
 
Creating, altering and dropping tables
Creating, altering and dropping tablesCreating, altering and dropping tables
Creating, altering and dropping tables
 
V15 like operator-c
V15 like operator-cV15 like operator-c
V15 like operator-c
 
Sql Keywords - You Need to Use
Sql Keywords - You Need to UseSql Keywords - You Need to Use
Sql Keywords - You Need to Use
 
Oracle sql joins
Oracle sql joinsOracle sql joins
Oracle sql joins
 
VLOOKUP Function - Marelen Talavera - Vivacious Analytic
VLOOKUP Function - Marelen Talavera - Vivacious AnalyticVLOOKUP Function - Marelen Talavera - Vivacious Analytic
VLOOKUP Function - Marelen Talavera - Vivacious Analytic
 
Vlookup - an introduction
Vlookup - an introductionVlookup - an introduction
Vlookup - an introduction
 
Mysql joins
Mysql joinsMysql joins
Mysql joins
 
PHP mysql Mysql joins
PHP mysql  Mysql joinsPHP mysql  Mysql joins
PHP mysql Mysql joins
 
Sql select statement
Sql select statementSql select statement
Sql select statement
 
Hira
HiraHira
Hira
 
MySQL JOINS
MySQL JOINSMySQL JOINS
MySQL JOINS
 
Filter
FilterFilter
Filter
 
Web app development_my_sql_09
Web app development_my_sql_09Web app development_my_sql_09
Web app development_my_sql_09
 
Guide To Mastering The MySQL Query Execution Plan
Guide To Mastering The MySQL Query Execution PlanGuide To Mastering The MySQL Query Execution Plan
Guide To Mastering The MySQL Query Execution Plan
 
How to use Hlookup find an exact match
How to use Hlookup find an exact match How to use Hlookup find an exact match
How to use Hlookup find an exact match
 

Similar to Indexes

Database index
Database indexDatabase index
Database indexRiteshkiit
 
Sql server ___________session_17(indexes)
Sql server  ___________session_17(indexes)Sql server  ___________session_17(indexes)
Sql server ___________session_17(indexes)Ehtisham Ali
 
Module08
Module08Module08
Module08Sridhar P
 
Sql overview-1232931296681161-1
Sql overview-1232931296681161-1Sql overview-1232931296681161-1
Sql overview-1232931296681161-1sagaroceanic11
 
Mysql cheatsheet
Mysql cheatsheetMysql cheatsheet
Mysql cheatsheetAdolfo Nasol
 
Sql introduction
Sql introductionSql introduction
Sql introductionBhavya Chawla
 
Sql server lesson6
Sql server lesson6Sql server lesson6
Sql server lesson6Ala Qunaibi
 
Sql slid
Sql slidSql slid
Sql slidpacatarpit
 
SQL -Beginner To Intermediate Level.pdf
SQL -Beginner To Intermediate Level.pdfSQL -Beginner To Intermediate Level.pdf
SQL -Beginner To Intermediate Level.pdfDraguClaudiu
 
Myth busters - performance tuning 101 2007
Myth busters - performance tuning 101 2007Myth busters - performance tuning 101 2007
Myth busters - performance tuning 101 2007paulguerin
 

Similar to Indexes (20)

Database index
Database indexDatabase index
Database index
 
Sql server ___________session_17(indexes)
Sql server  ___________session_17(indexes)Sql server  ___________session_17(indexes)
Sql server ___________session_17(indexes)
 
Sql index
Sql indexSql index
Sql index
 
SQL | DML
SQL | DMLSQL | DML
SQL | DML
 
MySQL INDEXES
MySQL INDEXESMySQL INDEXES
MySQL INDEXES
 
Index in sql server
Index in sql serverIndex in sql server
Index in sql server
 
Sql basics
Sql basicsSql basics
Sql basics
 
Module08
Module08Module08
Module08
 
Module08
Module08Module08
Module08
 
Sql overview-1232931296681161-1
Sql overview-1232931296681161-1Sql overview-1232931296681161-1
Sql overview-1232931296681161-1
 
MSSQL_Book.pdf
MSSQL_Book.pdfMSSQL_Book.pdf
MSSQL_Book.pdf
 
Oracle Index
Oracle IndexOracle Index
Oracle Index
 
Mysql cheatsheet
Mysql cheatsheetMysql cheatsheet
Mysql cheatsheet
 
Sql introduction
Sql introductionSql introduction
Sql introduction
 
SQL
SQLSQL
SQL
 
Sql server lesson6
Sql server lesson6Sql server lesson6
Sql server lesson6
 
Sql slid
Sql slidSql slid
Sql slid
 
SQL -Beginner To Intermediate Level.pdf
SQL -Beginner To Intermediate Level.pdfSQL -Beginner To Intermediate Level.pdf
SQL -Beginner To Intermediate Level.pdf
 
V25 sql index
V25 sql indexV25 sql index
V25 sql index
 
Myth busters - performance tuning 101 2007
Myth busters - performance tuning 101 2007Myth busters - performance tuning 101 2007
Myth busters - performance tuning 101 2007
 

More from Yaswanth Babu Gummadivelli (20)

Presentation on BA
Presentation on BAPresentation on BA
Presentation on BA
 
ERP
ERPERP
ERP
 
Ba -content
Ba -contentBa -content
Ba -content
 
E commerce use case documentation.
E commerce use case documentation.E commerce use case documentation.
E commerce use case documentation.
 
MOM on activity diagram
MOM on activity diagramMOM on activity diagram
MOM on activity diagram
 
UML Diagrams
UML DiagramsUML Diagrams
UML Diagrams
 
Business analyst ppt
Business analyst pptBusiness analyst ppt
Business analyst ppt
 
MOM on BA
MOM on BAMOM on BA
MOM on BA
 
exception handling
 exception handling exception handling
exception handling
 
collections
 collections collections
collections
 
Constructors
Constructors Constructors
Constructors
 
array
array array
array
 
Use case for atm
Use case for atmUse case for atm
Use case for atm
 
use case diagramHospital managment system
use case diagramHospital managment systemuse case diagramHospital managment system
use case diagramHospital managment system
 
Activity diagram for ticket vending machine
Activity diagram for ticket vending machineActivity diagram for ticket vending machine
Activity diagram for ticket vending machine
 
Extreme programming
Extreme programmingExtreme programming
Extreme programming
 
Agile model
Agile model Agile model
Agile model
 
Business Analyst
Business AnalystBusiness Analyst
Business Analyst
 
CRM and ERP
CRM and ERPCRM and ERP
CRM and ERP
 
Reflection
ReflectionReflection
Reflection
 

Recently uploaded

Blooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxBlooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxUnboundStockton
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Celine George
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupJonathanParaisoCruz
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...jaredbarbolino94
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.arsicmarija21
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...JhezDiaz1
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxDr.Ibrahim Hassaan
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaVirag Sontakke
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
MICROBIOLOGY biochemical test detailed.pptx
MICROBIOLOGY biochemical test detailed.pptxMICROBIOLOGY biochemical test detailed.pptx
MICROBIOLOGY biochemical test detailed.pptxabhijeetpadhi001
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Jisc
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 

Recently uploaded (20)

Blooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxBlooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docx
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized Group
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptx
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of India
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
MICROBIOLOGY biochemical test detailed.pptx
MICROBIOLOGY biochemical test detailed.pptxMICROBIOLOGY biochemical test detailed.pptx
MICROBIOLOGY biochemical test detailed.pptx
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 

Indexes

  • 1. Indexes: Index is used for faster access of data from table and will show records in the table in ascending order or descending order. Index in SQLSERVER will works automaticall.there is no need to open or to close and index. Types of indexes: 1. Clustered index 2. non-clustered index Clustered index: 1. A table can contain only one clustered index. If table contains primary key column then on that column clustered index will work. 2. This index will change the physical order of records in the table based on indexed column. Non-clustered index: 1. A table can contain 249 non-clustered indexes. 2. If table contains uni-constraints then on that column non clustered index will work.it will not change the physical order of records in the table but with the help of reference (book index & index key) of the table. 3. it will show the records in ascending or descending order. SYNTAX: CREATE[UNIQUE][CLUSTERED/NON-CLUSTERED] INDEX<INDEX_NAME> ON<TABLE_NAME>(<COLUMN_NAME>[DESC]) TO DELETE INDEX: DROP INDEX<TABLE_NAME><INDEX_NAME> CLUSTERED INDEX: CREATE CLUSTEREDINDEX MYINDEX1 ON EMPLOYEE(ENO) SELECT * FROM EMPLOYEE (ENO WILL BE IN ASCENDING ORDER)
  • 2. DROP INDEX EMPLOYEE.MYINDEX1 SELECT * FROM EMPLOYEE (ENO WILL BE IN ASCENDING ORDER) NON-CLUSTERED INDEX: CREATE NONCLUSTEREDINDEX MYINDEX2 ON EMPLIST (ENO) INCLUDE(ENAME,SAL) SELECT * FROM EMPLIST (ENO WILL BE IN ASCENDING ORDER) DROP INDEX EMPLIST.MYINDEX2 SELECTR * FROM EMPLIST (ENO WILL BE IN PREVIOUS ORDER) MULTIPLE NONCLUSTERED INDEX: CREATE NONCLUSTEREDINDEX MYINDEX3 ON EMPLOYEE(ENO) INCLUDE(ENAME,SAL) CREATE NONCLUSTEREDINDEX MYINDEX4 ON EMPLOYEE(SAL) INCLUDE(ENAME,SAL) SELECT * FROM EMPLOYEE WHERE ENO>100 SELECT * FROM EMPLOYEE WHERE SAL>1000 NOTE: If The Table Contains Multiple Nonclustered Indexes Then Two Conditions Should Be Satisfied 1. Select Statement With Where Clause 2. Indexed Column In Where Clause