问题
In MySQL how to use the Index concept for MySQL tables.
回答1:
Syntax for adding index to existing table.
ALTER TABLE table_name ADD INDEX column_name
A simple example
CREATE TABLE employee_records (name VARCHAR(50), employeeID INT);
CREATE INDEX id_index ON employee_records(employeeID);
creating index while creating table
CREATE TABLE employee_records (
name VARCHAR(50),
employeeID INT, INDEX (employeeID)
);
回答2:
To add an index to a table in MySQL:
ALTER TABLE [table name] ADD INDEX ([column name], ...);
回答3:
ALTER TABLE table_name ADD INDEX index_name (col_name)
OR
CREATE INDEX index_name ON table_name(index_name)
来源:https://stackoverflow.com/questions/6731048/in-mysql-how-to-set-index-to-the-table