SlideShare a Scribd company logo
1 of 13
By : Dhirendra Chauhan
SQL-Indexes
SQL-Indexes
“Indexes are used to retrieve data from the
database more quickly than otherwise. The
users cannot see the indexes, they are just
used to speed up searches/queries.”
Create Indexes In MySql
The CREATE INDEX statement is used
to create indexes in tables.
Syntax
CREATE INDEX index_name ON table_name (column1, column2, ...);
Example
CREATE INDEX empsalary ON employee(ID, salary);
Create Indexes
creating table time
CREATE INDEX index_name
ON table_name (column1, column2, ...);
Example
CREATE INDEX index_name
ON table_name (column1, column2, ...);
Syntax
Show Indexes from Database
You can specify the database name if you are not
connected to any database or you want to get the
index information of a table in a different
database:
SHOW INDEXES FROM table_name
IN database_name;
SHOW INDEXES FROM Employee IN Mount;
Example
Syntax
Drop Indexes In MySql
The DROP INDEX statement is used to
delete an index in a table.
Syntax
DROP INDEX index_name
ON table_name;
Example
DROP INDEX index_name
ON table_name;
Rename the Index Name
We can also rename an index using command .
Alter table tableName
Rename Index Index_Name To New Index_Name;
Example
Syntax
Alter table tableName
Rename Index Index_Name To New Index_Name;
Show Indexes
SHOW INDEX returns table index information.
SHOW INDEX FROM TableName;
SHOW INDEX FROM mytable;
Example
Syntax
Show Indexes from Database
The following query is similar to the one above
SHOW INDEXES FROM database_name . table_name;
SHOW INDEXES FROM Mount . Employee;
Example
Syntax
Advantages of indexes
1. Speed up SELECT query
2. Helps to make a row unique or without duplicates(Primary ,
Unique)
3. If index is set to fill-text index, then we can search against
large string values. for example to find a word from a
sentence etc.
Disadvantages of indexes
1.Indexes take additional disk space.
2.indexes slow down INSERT,UPDATE and DELETE,
but will speed up UPDATE if the WHERE condition
has an indexed field. INSERT, UPDATE and
DELETE becomes slower because on each operation
the indexes must also be updated.
THANK
YOU

More Related Content

What's hot

Access Reports for Tenderfeet (or is that tenderfoots?)
Access Reports for Tenderfeet (or is that tenderfoots?) Access Reports for Tenderfeet (or is that tenderfoots?)
Access Reports for Tenderfeet (or is that tenderfoots?) Alan Manifold
 
Sql select statement
Sql select statementSql select statement
Sql select statementVivek Singh
 
Microsoft Tech Club Cairo University "MSTC'16 Builders and Developers " Sessi...
Microsoft Tech Club Cairo University "MSTC'16 Builders and Developers " Sessi...Microsoft Tech Club Cairo University "MSTC'16 Builders and Developers " Sessi...
Microsoft Tech Club Cairo University "MSTC'16 Builders and Developers " Sessi...Wagdy Mohamed
 
Introduction of sql server indexing
Introduction of sql server indexingIntroduction of sql server indexing
Introduction of sql server indexingMahabubur Rahaman
 
SQL Server Index and Partition Strategy
SQL Server Index and Partition StrategySQL Server Index and Partition Strategy
SQL Server Index and Partition StrategyHamid J. Fard
 
SQL for Data Science Tutorial | Data Science Tutorial | Edureka
SQL for Data Science Tutorial | Data Science Tutorial | EdurekaSQL for Data Science Tutorial | Data Science Tutorial | Edureka
SQL for Data Science Tutorial | Data Science Tutorial | EdurekaEdureka!
 
07 ohp slides 1 - INDEXES
07 ohp slides 1 - INDEXES07 ohp slides 1 - INDEXES
07 ohp slides 1 - INDEXESAnne Lee
 
How did i steal your database CSCamp2011
How did i steal your database CSCamp2011How did i steal your database CSCamp2011
How did i steal your database CSCamp2011Mostafa Siraj
 
Mysql Crud, Php Mysql, php, sql
Mysql Crud, Php Mysql, php, sqlMysql Crud, Php Mysql, php, sql
Mysql Crud, Php Mysql, php, sqlAimal Miakhel
 
Indexes: The Second Pillar of Database Wisdom
Indexes: The Second Pillar of Database WisdomIndexes: The Second Pillar of Database Wisdom
Indexes: The Second Pillar of Database Wisdomgisborne
 
Sql basic things
Sql basic thingsSql basic things
Sql basic thingsNishil Jain
 
Sql server ___________ (advance sql)
Sql server  ___________  (advance sql)Sql server  ___________  (advance sql)
Sql server ___________ (advance sql)Ehtisham Ali
 

What's hot (13)

Access Reports for Tenderfeet (or is that tenderfoots?)
Access Reports for Tenderfeet (or is that tenderfoots?) Access Reports for Tenderfeet (or is that tenderfoots?)
Access Reports for Tenderfeet (or is that tenderfoots?)
 
Sql select statement
Sql select statementSql select statement
Sql select statement
 
Microsoft Tech Club Cairo University "MSTC'16 Builders and Developers " Sessi...
Microsoft Tech Club Cairo University "MSTC'16 Builders and Developers " Sessi...Microsoft Tech Club Cairo University "MSTC'16 Builders and Developers " Sessi...
Microsoft Tech Club Cairo University "MSTC'16 Builders and Developers " Sessi...
 
Mysql cheatsheet
Mysql cheatsheetMysql cheatsheet
Mysql cheatsheet
 
Introduction of sql server indexing
Introduction of sql server indexingIntroduction of sql server indexing
Introduction of sql server indexing
 
SQL Server Index and Partition Strategy
SQL Server Index and Partition StrategySQL Server Index and Partition Strategy
SQL Server Index and Partition Strategy
 
SQL for Data Science Tutorial | Data Science Tutorial | Edureka
SQL for Data Science Tutorial | Data Science Tutorial | EdurekaSQL for Data Science Tutorial | Data Science Tutorial | Edureka
SQL for Data Science Tutorial | Data Science Tutorial | Edureka
 
07 ohp slides 1 - INDEXES
07 ohp slides 1 - INDEXES07 ohp slides 1 - INDEXES
07 ohp slides 1 - INDEXES
 
How did i steal your database CSCamp2011
How did i steal your database CSCamp2011How did i steal your database CSCamp2011
How did i steal your database CSCamp2011
 
Mysql Crud, Php Mysql, php, sql
Mysql Crud, Php Mysql, php, sqlMysql Crud, Php Mysql, php, sql
Mysql Crud, Php Mysql, php, sql
 
Indexes: The Second Pillar of Database Wisdom
Indexes: The Second Pillar of Database WisdomIndexes: The Second Pillar of Database Wisdom
Indexes: The Second Pillar of Database Wisdom
 
Sql basic things
Sql basic thingsSql basic things
Sql basic things
 
Sql server ___________ (advance sql)
Sql server  ___________  (advance sql)Sql server  ___________  (advance sql)
Sql server ___________ (advance sql)
 

Similar to V25 sql index

Sql tutorial
Sql tutorialSql tutorial
Sql tutorialamitabros
 
Relational Database Language.pptx
Relational Database Language.pptxRelational Database Language.pptx
Relational Database Language.pptxSheethal Aji Mani
 
Data Manipulation Language.pptx
Data Manipulation Language.pptxData Manipulation Language.pptx
Data Manipulation Language.pptxEllenGracePorras
 
Sql – Structured Query Language
Sql – Structured Query LanguageSql – Structured Query Language
Sql – Structured Query Languagepandey3045_bit
 
SQL.pptx for the begineers and good know
SQL.pptx for the begineers and good knowSQL.pptx for the begineers and good know
SQL.pptx for the begineers and good knowPavithSingh
 
Sydney Oracle Meetup - indexes
Sydney Oracle Meetup - indexesSydney Oracle Meetup - indexes
Sydney Oracle Meetup - indexespaulguerin
 
PPT of Common Table Expression (CTE), Window Functions, JOINS, SubQuery
PPT  of Common Table Expression (CTE), Window Functions, JOINS, SubQueryPPT  of Common Table Expression (CTE), Window Functions, JOINS, SubQuery
PPT of Common Table Expression (CTE), Window Functions, JOINS, SubQueryAbhishek590097
 
Steps towards of sql server developer
Steps towards of sql server developerSteps towards of sql server developer
Steps towards of sql server developerAhsan Kabir
 

Similar to V25 sql index (20)

Module08
Module08Module08
Module08
 
Les12
Les12Les12
Les12
 
MySQL INDEXES
MySQL INDEXESMySQL INDEXES
MySQL INDEXES
 
Oracle Index
Oracle IndexOracle Index
Oracle Index
 
Sql tutorial
Sql tutorialSql tutorial
Sql tutorial
 
lovely
lovelylovely
lovely
 
Relational Database Language.pptx
Relational Database Language.pptxRelational Database Language.pptx
Relational Database Language.pptx
 
Data Manipulation Language.pptx
Data Manipulation Language.pptxData Manipulation Language.pptx
Data Manipulation Language.pptx
 
Sql – Structured Query Language
Sql – Structured Query LanguageSql – Structured Query Language
Sql – Structured Query Language
 
Sql12
Sql12Sql12
Sql12
 
SQL.pptx for the begineers and good know
SQL.pptx for the begineers and good knowSQL.pptx for the begineers and good know
SQL.pptx for the begineers and good know
 
Les13
Les13Les13
Les13
 
sql.pptx
sql.pptxsql.pptx
sql.pptx
 
Sql index
Sql indexSql index
Sql index
 
MYSQL.ppt
MYSQL.pptMYSQL.ppt
MYSQL.ppt
 
Module 3
Module 3Module 3
Module 3
 
Sydney Oracle Meetup - indexes
Sydney Oracle Meetup - indexesSydney Oracle Meetup - indexes
Sydney Oracle Meetup - indexes
 
PPT of Common Table Expression (CTE), Window Functions, JOINS, SubQuery
PPT  of Common Table Expression (CTE), Window Functions, JOINS, SubQueryPPT  of Common Table Expression (CTE), Window Functions, JOINS, SubQuery
PPT of Common Table Expression (CTE), Window Functions, JOINS, SubQuery
 
DBMS LAB M.docx
DBMS LAB M.docxDBMS LAB M.docx
DBMS LAB M.docx
 
Steps towards of sql server developer
Steps towards of sql server developerSteps towards of sql server developer
Steps towards of sql server developer
 

More from Dhirendra Chauhan (20)

V35 keys-c
V35  keys-cV35  keys-c
V35 keys-c
 
V34 numeric function-c
V34  numeric function-cV34  numeric function-c
V34 numeric function-c
 
V33 date function-c
V33  date function-cV33  date function-c
V33 date function-c
 
V31 having
V31  havingV31  having
V31 having
 
V30 full join(union intersect etc)
V30  full join(union intersect etc)V30  full join(union intersect etc)
V30 full join(union intersect etc)
 
V29 group by-c
V29  group by-cV29  group by-c
V29 group by-c
 
V28 view
V28  viewV28  view
V28 view
 
V27 constraint
V27 constraintV27 constraint
V27 constraint
 
V26 key
V26 keyV26 key
V26 key
 
V24 cartesion product-c
V24 cartesion product-cV24 cartesion product-c
V24 cartesion product-c
 
V23 function-2
V23 function-2V23 function-2
V23 function-2
 
V22 function-1
V22 function-1V22 function-1
V22 function-1
 
V21 in operator
V21 in operatorV21 in operator
V21 in operator
 
V20 bet ween operator-c
V20 bet ween operator-cV20 bet ween operator-c
V20 bet ween operator-c
 
V19 join method-c
V19 join method-cV19 join method-c
V19 join method-c
 
V18 alias-c
V18 alias-cV18 alias-c
V18 alias-c
 
V17 show command-c
V17 show command-cV17 show command-c
V17 show command-c
 
V16 sql comments-c
V16 sql comments-cV16 sql comments-c
V16 sql comments-c
 
V15 like operator-c
V15 like operator-cV15 like operator-c
V15 like operator-c
 
V3 employment-unemployment
V3 employment-unemploymentV3 employment-unemployment
V3 employment-unemployment
 

Recently uploaded

Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...Pooja Nehwal
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room servicediscovermytutordmt
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
The byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxThe byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxShobhayan Kirtania
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 

Recently uploaded (20)

Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room service
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
The byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxThe byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptx
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 

V25 sql index

  • 1. By : Dhirendra Chauhan
  • 3. SQL-Indexes “Indexes are used to retrieve data from the database more quickly than otherwise. The users cannot see the indexes, they are just used to speed up searches/queries.”
  • 4. Create Indexes In MySql The CREATE INDEX statement is used to create indexes in tables. Syntax CREATE INDEX index_name ON table_name (column1, column2, ...); Example CREATE INDEX empsalary ON employee(ID, salary);
  • 5. Create Indexes creating table time CREATE INDEX index_name ON table_name (column1, column2, ...); Example CREATE INDEX index_name ON table_name (column1, column2, ...); Syntax
  • 6. Show Indexes from Database You can specify the database name if you are not connected to any database or you want to get the index information of a table in a different database: SHOW INDEXES FROM table_name IN database_name; SHOW INDEXES FROM Employee IN Mount; Example Syntax
  • 7. Drop Indexes In MySql The DROP INDEX statement is used to delete an index in a table. Syntax DROP INDEX index_name ON table_name; Example DROP INDEX index_name ON table_name;
  • 8. Rename the Index Name We can also rename an index using command . Alter table tableName Rename Index Index_Name To New Index_Name; Example Syntax Alter table tableName Rename Index Index_Name To New Index_Name;
  • 9. Show Indexes SHOW INDEX returns table index information. SHOW INDEX FROM TableName; SHOW INDEX FROM mytable; Example Syntax
  • 10. Show Indexes from Database The following query is similar to the one above SHOW INDEXES FROM database_name . table_name; SHOW INDEXES FROM Mount . Employee; Example Syntax
  • 11. Advantages of indexes 1. Speed up SELECT query 2. Helps to make a row unique or without duplicates(Primary , Unique) 3. If index is set to fill-text index, then we can search against large string values. for example to find a word from a sentence etc.
  • 12. Disadvantages of indexes 1.Indexes take additional disk space. 2.indexes slow down INSERT,UPDATE and DELETE, but will speed up UPDATE if the WHERE condition has an indexed field. INSERT, UPDATE and DELETE becomes slower because on each operation the indexes must also be updated.