SQL CREATE INDEX Statement

The CREATE INDEX statement is used to create indexes in the table which is required to retrieve the records from the database more quickly than other methods. The visibility of indexes is not available, it is just used to speed up the queries and statements. The updates on the tables that consist of indexes need more time than the table without indexes.
- Syntax to CREATE INDEX Statement –
CREATE INDEX index_name
ON table_name (column1, column2, ...);
This syntax will allow the duplicate values in the table.
CREATE UNIQUE INDEX index_name
ON table_name (column1, column2, ...);
The UNIQUE keyword in the syntax will restrict the duplicate values to get inserted into the table.
Demo Table –
Science_Students
| Student_id | Student_name | Address | Phone number | Age | Grade |
| 1 | Simon | Chicago | 5687466 | 18 | A+ |
| 2 | Alvin | Mexico | 6321478 | 19 | A+ |
| 3 | Theo | Paris | 3362473 | 18 | B |
| 4 | Brittany | New York | 6632147 | 19 | C |
| 5 | Jenette | Chicago | 9211627 | 16 | A+ |
| 6 | Jerry | Beverly Hills | 3652877 | 18 | F |
Example – Create an index named “idx_name” on the “Student_Name” column in the Science_Students table –
CREATE INDEX idx_name
ON Science_Students (Student_Name);
DROP INDEX Statement –
We know that the “DROP” keyword is used to delete records, so the “DROP INDEX” deletes the index created on the table.
- Syntax to DROP INDEX –
DROP INDEX table_name.index_name;
Other SQL topics to check out:
- What is RDBMS (Relational Database Management System)?
- SQL SELECT Statement
- SQL INSERT INTO SELECT Statement
- SQL ALL Operator
- SQL WHERE Clause
- SQL AND Operator
- SQL OR Operator
Follow us on Twitter, Facebook, Linkedin, and Tableau Public to stay updated with our latest blog and what’s new in Tableau.
If you are looking forward to getting your data pipeline built and setting up the dashboard for business intelligence, book a call now from here.
#analytics #data #business #artificialintelligence #machinelearning #startup #deeplearning #deeplearning #datascience #ai #growth #dataanalytics #india #datascientist #powerbi #dataanalysis #tableau #SQL #businessanalytics #businessanalyst #businessandmanagement #dataanalyst #businessanalysis #analyst #analysis #powerbideveloper #powerbidesktop #letsviz


