In MySQL, INDEX
constraint are used to speed up data retrieval from database table. To create INDEX
in MySQL, CREATE INDEX statement is used to create indexes in tables. MySQL allows to create multiple-column INDEX
.
To create indexes in tables using CREATE INDEX statement, use the following syntax:
Parameters:
indexname: Name of the INDEX, you want to create.
tablename: The table name from which you want to fetch records.
col1: The column name on which you want to create index.
INDEX
on "custId" column for "tblCustomer" table:
CREATE UNIQUE INDEX
statement, use the following syntax:
UNIQUE INDEX
on "custId" column for "tblCustomer" table:
INDEX
constraint "idex_custId" from "tblCustomer" table: