mysql创建索引的sql语句
时间: 2023-09-21 21:03:52 浏览: 141
SQL语句创建
在MySQL中,创建索引的SQL语句包括以下几种形式:
1. 主键索引(PRIMARY KEY):
ALTER TABLE table_name ADD PRIMARY KEY (column);
2. 唯一索引(UNIQUE):
ALTER TABLE table_name ADD UNIQUE (column);
3. 普通索引(INDEX):
ALTER TABLE table_name ADD INDEX index_name (column);
4. 全文索引(FULLTEXT):
ALTER TABLE table_name ADD FULLTEXT (column);
5. 组合索引(多列索引):
ALTER TABLE table_name ADD INDEX index_name (column1,column2,column3);
在创建组合索引时,可以使用以下语句:
CREATE INDEX index_name ON table_name (column1, column2, ...);
在创建普通索引时,可以使用以下语句:
CREATE INDEX index_name ON table_name (column_name);<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [mysql 创建索引语句](https://blog.csdn.net/m0_67390788/article/details/126595998)[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^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
- *2* *3* [MySQL索引创建](https://blog.csdn.net/qq_58616732/article/details/130876868)[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^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文