SlideShare a Scribd company logo
8/10/13 SQL Index
beginner-sql-tutorial.com/sql-index.htm 1/2
SQL Index
Index in sql is created on existing tables to retrieve the rows quickly.
When there are thousands of records in a table, retrieving information will take a long time. Therefore indexes
are created on columns which are accessed frequently, so that the information can be retrieved quickly. Indexes
can be created on a single column or a group of columns. When a index is created, it first sorts the data and
then it assigns a ROWID for each row.
Syntax to create Index:
CREATE INDEX index_name
ON table_name (column_name1,column_name2...);
Syntax to create SQL unique Index:
CREATE UNIQUE INDEX index_name
ON table_name (column_name1,column_name2...);
index_name is the name of the INDEX.
table_name is the name of the table to which the indexed column belongs.
column_name1, column_name2.. is the list of columns which make up the INDEX.
In Oracle there are two types of SQL index namely, implicit and explicit.
Implicit Indexes:
They are created when a column is explicity defined with PRIMARY KEY, UNIQUE KEY Constraint.
Explicit Indexes:
They are created using the "create index.. " syntax.
NOTE:
8/10/13 SQL Index
beginner-sql-tutorial.com/sql-index.htm 2/2
1) Even though sql indexes are created to access the rows in the table quickly, they slow down DML operations
like INSERT, UPDATE, DELETE on the table, because the indexes and tables both are updated along when a DML
operation is performed. So use indexes only on columns which are used to search the table frequently.
2) Is is not required to create indexes on table which have less data.
3) In oracle database you can define up to sixteen (16) columns in an INDEX.

More Related Content

PDF
MySQL INDEXES
PPTX
Oracle Index
PPTX
Sql server ___________session_17(indexes)
PPTX
PPTX
Database index
DOC
Sql queries with answers
PDF
DBMS and SQL Questions and Answers (1).pdf
MySQL INDEXES
Oracle Index
Sql server ___________session_17(indexes)
Database index
Sql queries with answers
DBMS and SQL Questions and Answers (1).pdf

Similar to Sql index (20)

PPTX
V25 sql index
DOCX
Index in sql server
PPT
Module08
PPT
Module08
PPT
Sequences and indexes
PPT
PPTX
PDF
Sql12
PPT
SQL WORKSHOP::Lecture 13
PDF
Concepts of NonStop SQL/MX: Part 3 - Introduction to Metadata
PDF
Concepts of NonStop SQL/MX: Part 2 - Introduction to catalogs and other objects
PPT
Les13[1]Other Database Objects
PPTX
SQL OVERVIEW for a new introduced student.pptx
PDF
Oracle SQL Part1
PPTX
sql12.pptxsql12.pptxsql12.pptxsql12.pptx
PPT
PPTX
sql.pptx
PPT
1_SQL_11_13_Notes_on_how_to_gain_knowledge.ppt
PPT
Database Application for La Salle
PDF
Sql tutorial
V25 sql index
Index in sql server
Module08
Module08
Sequences and indexes
Sql12
SQL WORKSHOP::Lecture 13
Concepts of NonStop SQL/MX: Part 3 - Introduction to Metadata
Concepts of NonStop SQL/MX: Part 2 - Introduction to catalogs and other objects
Les13[1]Other Database Objects
SQL OVERVIEW for a new introduced student.pptx
Oracle SQL Part1
sql12.pptxsql12.pptxsql12.pptxsql12.pptx
sql.pptx
1_SQL_11_13_Notes_on_how_to_gain_knowledge.ppt
Database Application for La Salle
Sql tutorial
Ad

More from Vivek Singh (20)

PPS
C programming session 14
PPS
C programming session 13
PPS
C programming session 11
PPS
C programming session 10
PPS
C programming session 08
PPS
C programming session 07
PPS
C programming session 05
PPS
C programming session 04
PPS
C programming session 02
PPS
C programming session 01
PPS
C programming session 16
PDF
Niit aptitude question paper
PDF
Excel shortcut and tips
PDF
Sql where clause
PDF
Sql update statement
PDF
Sql tutorial, tutorials sql
PDF
Sql subquery
PDF
Sql select statement
PDF
Sql rename
PDF
Sql query tuning or query optimization
C programming session 14
C programming session 13
C programming session 11
C programming session 10
C programming session 08
C programming session 07
C programming session 05
C programming session 04
C programming session 02
C programming session 01
C programming session 16
Niit aptitude question paper
Excel shortcut and tips
Sql where clause
Sql update statement
Sql tutorial, tutorials sql
Sql subquery
Sql select statement
Sql rename
Sql query tuning or query optimization
Ad

Recently uploaded (20)

PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PPTX
Pharma ospi slides which help in ospi learning
PPTX
PPH.pptx obstetrics and gynecology in nursing
PDF
Insiders guide to clinical Medicine.pdf
PPTX
GDM (1) (1).pptx small presentation for students
PDF
O7-L3 Supply Chain Operations - ICLT Program
PDF
01-Introduction-to-Information-Management.pdf
PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PPTX
master seminar digital applications in india
PDF
Microbial disease of the cardiovascular and lymphatic systems
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PPTX
Renaissance Architecture: A Journey from Faith to Humanism
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PDF
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
PDF
RMMM.pdf make it easy to upload and study
PDF
Anesthesia in Laparoscopic Surgery in India
human mycosis Human fungal infections are called human mycosis..pptx
Supply Chain Operations Speaking Notes -ICLT Program
Pharma ospi slides which help in ospi learning
PPH.pptx obstetrics and gynecology in nursing
Insiders guide to clinical Medicine.pdf
GDM (1) (1).pptx small presentation for students
O7-L3 Supply Chain Operations - ICLT Program
01-Introduction-to-Information-Management.pdf
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
master seminar digital applications in india
Microbial disease of the cardiovascular and lymphatic systems
Final Presentation General Medicine 03-08-2024.pptx
Microbial diseases, their pathogenesis and prophylaxis
Renaissance Architecture: A Journey from Faith to Humanism
102 student loan defaulters named and shamed – Is someone you know on the list?
O5-L3 Freight Transport Ops (International) V1.pdf
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
RMMM.pdf make it easy to upload and study
Anesthesia in Laparoscopic Surgery in India

Sql index

  • 1. 8/10/13 SQL Index beginner-sql-tutorial.com/sql-index.htm 1/2 SQL Index Index in sql is created on existing tables to retrieve the rows quickly. When there are thousands of records in a table, retrieving information will take a long time. Therefore indexes are created on columns which are accessed frequently, so that the information can be retrieved quickly. Indexes can be created on a single column or a group of columns. When a index is created, it first sorts the data and then it assigns a ROWID for each row. Syntax to create Index: CREATE INDEX index_name ON table_name (column_name1,column_name2...); Syntax to create SQL unique Index: CREATE UNIQUE INDEX index_name ON table_name (column_name1,column_name2...); index_name is the name of the INDEX. table_name is the name of the table to which the indexed column belongs. column_name1, column_name2.. is the list of columns which make up the INDEX. In Oracle there are two types of SQL index namely, implicit and explicit. Implicit Indexes: They are created when a column is explicity defined with PRIMARY KEY, UNIQUE KEY Constraint. Explicit Indexes: They are created using the "create index.. " syntax. NOTE:
  • 2. 8/10/13 SQL Index beginner-sql-tutorial.com/sql-index.htm 2/2 1) Even though sql indexes are created to access the rows in the table quickly, they slow down DML operations like INSERT, UPDATE, DELETE on the table, because the indexes and tables both are updated along when a DML operation is performed. So use indexes only on columns which are used to search the table frequently. 2) Is is not required to create indexes on table which have less data. 3) In oracle database you can define up to sixteen (16) columns in an INDEX.