Skip to content

Create Index in the MySQL Table

Indexes allow the database application to find data fast, without reading the whole table.The CREATE INDEX statement is used to create indexes in tables.

CREATE INDEX Syntax

CREATE INDEX index_name ON table_name (column_name)

CREATE UNIQUE INDEX Syntax

 CREATE UNIQUE INDEX index_name ON table_name (column_name)

Example :
Create an index named username_index for the field username:

CREATE INDEX username_index ON users (username) USING BTREE;

If you want to create an index on a combination of columns, you can list the column names within the parentheses, separated by commas as shown below

CREATE INDEX user_index ON users (username,email) USING BTREE;

you can find more about index at : http://dev.mysql.com/doc/refman/5.0/en/create-index.html

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments