- Introduction To MySQL
- MySQL RDBMS
- MySQL SQL
- MySQL SELECT Statement
- MySQL WHERE Clause
- MySQL AND, OR And NOT Operators
- MySQL ORDER BY Keyword
- MySQL INSERT INTO Statement
- MySQL NULL Values
- MySQL UPDATE Statement
- MySQL DELETE Statement
- MySQL LIMIT Clause
- MySQL MIN() And MAX() Functions
- MySQL COUNT(), AVG() And SUM() Functions
- MySQL LIKE Operator
- MySQL Wildcards
- MySQL IN Operator
- MySQL BETWEEN
- MySQL Aliases
- MySQL Joins
- MySQL INNER JOIN Keyword
- MySQL LEFT JOIN Keyword
- MySQL RIGHT JOIN Keyword
- MySQL CROSS JOIN Keyword
- MySQL Self Join
- MySQL UNION Operator
- MySQL GROUP BY Statement
- MySQL HAVING Clause
- MySQL EXISTS Operator
- MySQL ANY And ALL Operators
- MySQL INSERT INTO SELECT Statement
- MySQL CASE Statement
- MySQL NULL Functions
- MySQL Comments
- MySQL Operators
- MySQL CREATE DATABASE Statement
- MySQL DROP DATABASE Statement
- MySQL CREATE TABLE Statement
- MySQL DROP TABLE Statement
- MySQL ALTER TABLE Statement
- MySQL Constraints
- MySQL NOT NULL Constraint
- MySQL UNIQUE Constraint
- MySQL PRIMARY KEY Constraint
- MySQL FOREIGN KEY Constraint
- MySQL CHECK Constraint
- MySQL DEFAULT Constraint
- MySQL CREATE INDEX Statement
- MySQL AUTO INCREMENT Field
- MySQL Working With Dates
- MySQL Views
- MySQL Data Types
- MySQL Functions
MySQL CREATE INDEX Statement
MySQL 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.
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:
ON table_name (column1, column2, ...);
Practice Excercise Practice now
CREATE UNIQUE INDEX Syntax
Creates a unique index on a table. Duplicate values are not allowed:
ON table_name (column1, column2, ...);
Practice Excercise Practice now
MySQL CREATE INDEX Example
The SQL statement below creates an index named "idx_lastname" on the "LastName" column in the "Persons" table:
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:
ON Persons (LastName, FirstName);
Practice Excercise Practice now
DROP INDEX Statement
The DROP INDEX statement is used to delete an index in a table.
DROP INDEX index_name;
Practice Excercise Practice now
Products
Partner
Copyright © RVR Innovations LLP 2024 | All rights reserved - Mytat.co is the venture of RVR Innovations LLP