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.
Create an index on a table :
CREATE INDEX indexname ON tablename (columnname1, columnname2, ...);
Create a unique index on a table –
CREATE UNIQUE INDEX indexname ON tablename (columnname1, columnname2, ...);
Below SQL statement would create an index named “idx_name” on the “LastName” column in the “GeeksTab” table –
CREATE INDEX idx_name 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.
DROP INDEX tablename.indexname;
DROP INDEX GeeksTab.idx_pname;
Attention reader! Don’t stop learning now. Get hold of all the important CS Theory concepts for SDE interviews with the CS Theory Course at a student-friendly price and become industry ready.
- Create, Alter and Drop schema in MS SQL Server
- Difference between Structured Query Language (SQL) and Transact-SQL (T-SQL)
- Difference between DELETE and DROP in SQL
- Difference between DROP and TRUNCATE in SQL
- SQL | DROP, TRUNCATE
- SQL | ALTER (ADD, DROP, MODIFY)
- Drop login in SQL Server
- DROP SCHEMA in SQL Server
- Neo4j Drop Index
- SQL | INSERT INTO Statement
- SQL | DELETE Statement
- SQL | UPDATE Statement
- SQL | INSERT IGNORE Statement
- SQL | Case Statement
- SQL | DESCRIBE Statement
- SQL | MERGE Statement
- MERGE Statement in SQL Explained
- Delete statement in MS SQL Server
- Reverse Statement Word by Word in SQL server
- SELECT INTO statement in SQL
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.