Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

CREATE and DROP INDEX Statement in SQL

  • Last Updated : 31 Aug, 2020

1. CREATE INDEX Statement :
The CREATE INDEX statement will create indexes in tables. Indexes are used for data procurement from the databases faster. The users cannot see the indexes, they are running in the background of queries, used to speed up searches/queries.

Syntax :
Create an index on a table :

Attention reader! Don’t stop learning now. Learn SQL for interviews using SQL Course  by GeeksforGeeks.

CREATE INDEX indexname
ON tablename (columnname1, columnname2, ...);

Create a unique index on a table –

ON tablename (columnname1, columnname2, ...);

Example –
Below SQL statement would create an index named “idx_name” on the “LastName” column in the “GeeksTab” table –

ON GeeksTab (LastName);

To create an index on multiple columns –

CREATE INDEX idx_pname
ON GeeksTab (LastName, FirstName);

2. DROP INDEX Statement :
The DROP INDEX statement could be used to remove an index from any table.

Syntax :

DROP INDEX tablename.indexname;

Example –

DROP INDEX GeeksTab.idx_pname;
My Personal Notes arrow_drop_up
Recommended Articles
Page :