Create an Index for a Given Table in MySQL

Q

How To Create an Index for a Given Table in MySQL?

✍: FYIcenter.com

A

If you have a table with a lots of rows, and you know that one of the columns will be used often as a search criteria, you can add an index for that column to improve the search performance. To add an index, you can use the "CREATE INDEX" statement as shown in the following script:

mysql> CREATE TABLE tip (id INTEGER PRIMARY KEY,
   subject VARCHAR(80) NOT NULL,
   description VARCHAR(256) NOT NULL,
   create_date DATE NULL);
Query OK, 0 rows affected (0.08 sec)

mysql> CREATE INDEX tip_subject ON tip(subject);
Query OK, 0 rows affected (0.19 sec)
Records: 0  Duplicates: 0  Warnings: 0

 

CREATE, ALTER and DROP Statements in MySQL

⇒⇒MySQL Database Tutorials

2016-10-16, 176👍, 0💬