mysql create table index
时间: 2024-02-04 18:02:49 浏览: 77
In MySQL, you can create an index on a table using the CREATE INDEX statement. The syntax is as follows:
```
CREATE [UNIQUE] INDEX index_name
ON table_name (column1, column2, ...);
```
- `index_name`: The name of the index you want to create.
- `table_name`: The name of the table on which you want to create the index.
- `column1, column2, ...`: The name of the columns that you want to include in the index.
The `UNIQUE` keyword is optional. If you include it, the index will only allow unique values to be inserted into the table.
Here's an example of how to create an index on a table:
```
CREATE INDEX idx_users_email
ON users (email);
```
This creates an index named `idx_users_email` on the `email` column in the `users` table. This index will help speed up queries that involve searching or sorting by email.
阅读全文