Main content of this article:
Show all indexes in the tableshow all index
Add index ADD INDEX, add Unique index add unique index
Multiple columns jointly add index, primary key
Keyword index vs key
show index from tb_name
For example:
show index from springdemo.blog;
ALTER TABLE `table` ADD INDEX `product_id` (`product_id`) # 创建唯一索引alter table tb_name add unique index `unique_idsrc_caffeversion` (`id_src`, `caffe_version`)
#多列索引ALTER TABLE `table` ADD INDEX `index_name` (`col1`,`col2`) # add primary key 添加主键ALTER TABLE `table_name` ADD PRIMARY KEY ( `column` )
When creating the table time, there is no difference between these two keywords, equivalent to synonyms
What are differences between Index v.s. Key in MySQL
CREATE TABLE tasks ( task_id INT UNSIGNED NOT NULL AUTO_INCREMENT, INDEX parent (parent_id), ....# However I found a code using KEY instead of INDEX as following....KEY order_date (order_date) ...
There’s no difference. They are synonyms.This was implemented for compatibility with other database systems.
The above is the detailed content of Detailed introduction to mysql index index related commands. For more information, please follow other related articles on the PHP Chinese website!