当前位置:网站首页>mysql怎么创建,删除,查看索引?
mysql怎么创建,删除,查看索引?
2022-07-07 10:36:00 【全栈程序员站长】
mysql是一个开源的应用非常广泛的数据库。mysql里面的索引能利用利用指针,能够大大提高查询效率。特别是当数据量非常大,查询涉及多个表时,使用索引往往能使查询速度加快成千上万倍。那么,怎么创建索引呢?
- 第一步,创建一个表,结构如下:create table t (id int unsigned not null,name varchar(20) not null default ‘-‘);
- 第二步,添加索引,二索引有分为几类,普通索引,主键索引,和唯一索引,如图就是步骤:图中数123就是对应普通索引,主键索引,和唯一索引 alter table 表名 add index/unique/primary key (索引名);
- 第三步,表里面已经有索引了,要怎么查看呢?用这两个命令:show index from table;或show keys from table;如图: show index from 表名; show keys from 表名;
- 第四步,有时候索引太多,会引起增删改查的性能,所以可以创建就可以删除,命令如下: drop index 索引名 on 表名; DROP INDEX index_name ON talbe_name; ALTER TABLE table_name DROP INDEX index_name; ALTER TABLE table_name DROP PRIMARY KEY;
- 第五步,在上面删除索引的时候,出现了错误,说不能发现索引名,是因为在第一次的时候已经删除了,所以,此索引名已经不存在了,如图
- 第六步,再次查询索引,是否有没有删除成功,重复第三步的命令,结果如图,说明已经删除了
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/113449.html原文链接:https://javaforall.cn
边栏推荐
- SQL lab 1~10 summary (subsequent continuous update)
- 图形对象的创建与赋值
- Niuke website
- leetcode刷题:二叉树20(二叉搜索树中的搜索)
- What if does not match your user account appears when submitting the code?
- Typescript interface inheritance
- Connect to blog method, overload, recursion
- Multi row and multi column flex layout
- H3C HCl MPLS layer 2 dedicated line experiment
- Configure an encrypted web server
猜你喜欢

The road to success in R & D efficiency of 1000 person Internet companies

什么是ESP/MSR 分区,如何建立ESP/MSR 分区

About IPSec

In the small skin panel, use CMD to enter the MySQL command, including the MySQL error unknown variable 'secure_ file_ Priv 'solution (super detailed)

leetcode刷题:二叉树25(二叉搜索树的最近公共祖先)
![[pytorch practice] use pytorch to realize image style migration based on neural network](/img/20/8ed7113115709b6169be289b0c280a.png)
[pytorch practice] use pytorch to realize image style migration based on neural network

【统计学习方法】学习笔记——提升方法

【深度学习】图像多标签分类任务,百度PaddleClas

Airserver automatically receives multi screen projection or cross device projection

Dialogue with Wang Wenyu, co-founder of ppio: integrate edge computing resources and explore more audio and video service scenarios
随机推荐
File upload vulnerability - upload labs (1~2)
[play RT thread] RT thread Studio - key control motor forward and reverse rotation, buzzer
SQL Lab (36~40) includes stack injection, MySQL_ real_ escape_ The difference between string and addslashes (continuous update after)
爱可可AI前沿推介(7.7)
VSCode的学习使用
<No. 9> 1805. Number of different integers in the string (simple)
On valuation model (II): PE index II - PE band
Idea 2021 Chinese garbled code
About web content security policy directive some test cases specified through meta elements
BGP third experiment report
Several ways to clear floating
Error in compiling libssl
【从 0 开始学微服务】【01】什么是微服务
Day-16 set
[pytorch practice] use pytorch to realize image style migration based on neural network
【从 0 开始学微服务】【00】课程概述
图形对象的创建与赋值
Attack and defense world ----- summary of web knowledge points
leetcode刷题:二叉树25(二叉搜索树的最近公共祖先)
Tutorial on principles and applications of database system (009) -- conceptual model and data model