Index

Create an Index (With Duplicate values)

Syntax

CREATE INDEX index_name
ON table_name (column1, column2, ...);

Example

CREATE INDEX `idx_email`
ON `student` (`email`);

Create Unique Index (Without Duplicate values)

Syntax

CREATE UNIQUE INDEX index_name
ON table_name (column1, column2, ...);

Example

CREATE UNIQUE INDEX `idx_email_name`
ON `student` (`email`, name);

Drop Index

Syntax

ALTER TABLE table_name
DROP INDEX index_name;

Example

ALTER TABLE `student`
DROP INDEX `idx_email_name`;

Last updated

Was this helpful?