0% found this document useful (0 votes)
2 views8 pages

SQL Create Index Statement

The SQL CREATE INDEX statement is used to create indexes in tables to enhance data retrieval speed. It allows for both standard and unique indexes, with specific syntax that may vary across different database systems. Additionally, the document outlines the DROP INDEX statement for deleting an index from a table.

Uploaded by

matias bahiru
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views8 pages

SQL Create Index Statement

The SQL CREATE INDEX statement is used to create indexes in tables to enhance data retrieval speed. It allows for both standard and unique indexes, with specific syntax that may vary across different database systems. Additionally, the document outlines the DROP INDEX statement for deleting an index from a table.

Uploaded by

matias bahiru
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

7/15/25, 9:38 AM SQL CREATE INDEX Statement

 Tutorials  Exercises  Services   Sign In

HTML
 CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C

SQL CREATE INDEX Statement


❮ Previous Next ❯

SQL CREATE INDEX Statement


The CREATE INDEX statement is used to create indexes in tables.

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.

Note: Updating a table with indexes takes more time than updating a table without
(because the indexes also need an update). So, only create indexes on columns that will
be frequently searched against.

CREATE INDEX Syntax


Creates an index on a table. Duplicate values are allowed:

CREATE INDEX index_name


ON table_name (column1, column2, ...);

CREATE UNIQUE INDEX Syntax


https://www.w3schools.com/sql/sql_create_index.asp 1/8
7/15/25, 9:38 AM SQL CREATE INDEX Statement

Creates a unique index on a table. Duplicate values are not allowed:


 Tutorials  Exercises  Services   Sign In

HTML
 CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C
CREATE UNIQUE INDEX index_name
ON table_name (column1, column2, ...);

Note: The syntax for creating indexes varies among different databases. Therefore:
Check the syntax for creating indexes in your database.

CREATE INDEX Example


The SQL statement below creates an index named "idx_lastname" on the "LastName"
column in the "Persons" table:

CREATE INDEX idx_lastname


ON Persons (LastName);

If you want to create an index on a combination of columns, you can list the column
names within the parentheses, separated by commas:

CREATE INDEX idx_pname


ON Persons (LastName, FirstName);

DROP INDEX Statement


The DROP INDEX statement is used to delete an index in a table.

MS Access:

https://www.w3schools.com/sql/sql_create_index.asp 2/8
7/15/25, 9:38 AM SQL CREATE INDEX Statement

DROP INDEX
Tutorials  Exercises  Services 
index_name ON table_name;
 Sign In

HTML
 CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C

SQL Server:

DROP INDEX table_name.index_name;

DB2/Oracle:

DROP INDEX index_name;

MySQL:

ALTER TABLE table_name


DROP INDEX index_name;

?
Exercise
What is the purpose of the SQL CREATE INDEX statement?

To create a backup of a table

To retrieve data more quickly by creating indexes

To ensure data integrity in a table

To delete an existing index in a table

https://www.w3schools.com/sql/sql_create_index.asp 3/8
7/15/25, 9:38 AM SQL CREATE INDEX Statement

 Tutorials  Exercises  Services 


Submit Answer »
 Sign In

HTML
 CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C

❮ Previous Next ❯

Track your progress - it's free! Sign Up Log in

ADVERTISEMENT

https://www.w3schools.com/sql/sql_create_index.asp 4/8
7/15/25, 9:38 AM SQL CREATE INDEX Statement

 Tutorials  Exercises  Services   Sign In

HTML
 CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C

https://www.w3schools.com/sql/sql_create_index.asp 5/8
7/15/25, 9:38 AM SQL CREATE INDEX Statement

COLOR PICKER 
 Tutorials  Exercises  Services  Sign In

HTML
 CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C



ADVERTISEMENT

ADVERTISEMENT

 

 PLUS SPACES

GET CERTIFIED FOR TEACHERS

https://www.w3schools.com/sql/sql_create_index.asp 6/8
7/15/25, 9:38 AM SQL CREATE INDEX Statement

 Tutorials  Exercises 
FOR BUSINESS
Services 
CONTACT US
 Sign In

HTML
 CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C

Top Tutorials
HTML Tutorial
CSS Tutorial
JavaScript Tutorial
How To Tutorial
SQL Tutorial
Python Tutorial
W3.CSS Tutorial
Bootstrap Tutorial
PHP Tutorial
Java Tutorial
C++ Tutorial
jQuery Tutorial

Top References
HTML Reference
CSS Reference
JavaScript Reference
SQL Reference
Python Reference
W3.CSS Reference
Bootstrap Reference
PHP Reference
HTML Colors
Java Reference
Angular Reference
jQuery Reference

Top Examples Get Certified


HTML Examples HTML Certificate
CSS Examples CSS Certificate
JavaScript Examples JavaScript Certificate
How To Examples Front End Certificate
SQL Examples SQL Certificate
Python Examples Python Certificate
W3.CSS Examples PHP Certificate
Bootstrap Examples jQuery Certificate
PHP Examples Java Certificate
Java Examples C++ Certificate
XML Examples C# Certificate
jQuery Examples XML Certificate

    

FORUM ABOUT ACADEMY


W3Schools is optimized for learning and training. Examples might be simplified to improve
reading and learning.
Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot

https://www.w3schools.com/sql/sql_create_index.asp 7/8
7/15/25, 9:38 AM SQL CREATE INDEX Statement
warrant full correctness

 of all content. While using W3Schools, you agree to have read and accepted our terms of use,
Tutorials  Exercises  Services 
cookie and privacy policy.
 Sign In

HTML
 Copyright
CSS 1999-2025 by Refsnes
JAVASCRIPT SQLData. PYTHON
All Rights Reserved.
JAVA W3Schools
PHP is Powered
HOW TOby W3.CSS.
W3.CSS C

https://www.w3schools.com/sql/sql_create_index.asp 8/8

You might also like