mysql 索引index_mysql索引index相关命令的详细介绍

软件安装:装机软件必备包

SQL是Structured Query Language(结构化查询语言)的缩写。SQL是专为数据库而建立的操作命令集,是一种功能齐全的数据库语言。在使用它时,只需要发出“做什么”的命令,“怎么做”是不用使用者考虑的。SQL功能强大、简单易学、使用方便,已经成为了数据库操作的基础,并且现在几乎所有的数据库均支持SQL。

本文主要内容:显示表中多有的索引show all index

添加索引ADD INDEX, 添加唯一索引add unique index

多列联合添加索引,primary key

关键词index vs key

show all index

show index from tb_name 例如:

show index from springdemo.blog;

43b9135e0e9eb021806e284d07936c97.png

添加索引ADD INDEX, 添加唯一索引add unique index

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` )

关键词index vs key

在创建表的时候,这两个关键词没什么区别,相当于同义词

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.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值