创建索引的mysql语句
时间: 2023-09-02 09:10:59 浏览: 101
创建索引的MySQL语句可以根据需要使用不同的索引类型。以下是一些常见的索引类型及其对应的MySQL语句:
1. 主键索引(PRIMARY KEY):
```mysql
ALTER TABLE `table_name` ADD PRIMARY KEY (`column`);
```
2. 唯一索引(UNIQUE):
```mysql
ALTER TABLE `table_name` ADD UNIQUE (`column`);
```
3. 普通索引(INDEX):
```mysql
ALTER TABLE `table_name` ADD INDEX `index_name` (`column`);
```
4. 全文索引(FULLTEXT):
```mysql
ALTER TABLE `table_name` ADD FULLTEXT (`column`);
```
5. 多列索引(组合索引):
```mysql
ALTER TABLE `table_name` ADD INDEX `index_name` (`column1`, `column2`, `column3`);
```
请根据您的需求选择适当的索引类型,并使用相应的MySQL语句创建索引。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [mysql 创建索引语句](https://blog.csdn.net/qq_34828100/article/details/109817642)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 50%"]
- *2* *3* [MySQL语句系列--索引的语句(创建/删除/查看)](https://blog.csdn.net/feiying0canglang/article/details/120520401)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文