当前位置:网站首页>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
边栏推荐
- Inverted index of ES underlying principle
- NPM instal reports agent or network problems
- 爱可可AI前沿推介(7.7)
- The left-hand side of an assignment expression may not be an optional property access. ts(2779)
- visual stdio 2017关于opencv4.1的环境配置
- 利用栈来实现二进制转化为十进制
- H3C HCl MPLS layer 2 dedicated line experiment
- How much does it cost to develop a small program mall?
- RHSA first day operation
- Idea 2021 Chinese garbled code
猜你喜欢
![[爬虫]使用selenium时,躲避脚本检测](/img/3a/85ea729be2aa76c3de4a822ca6939b.png)
[爬虫]使用selenium时,躲避脚本检测

Attack and defense world ----- summary of web knowledge points

VSCode的学习使用

What if does not match your user account appears when submitting the code?

【统计学习方法】学习笔记——第五章:决策树

Several methods of checking JS to judge empty objects

SQL lab 21~25 summary (subsequent continuous update) (including secondary injection explanation)

<No. 9> 1805. Number of different integers in the string (simple)

Static routing assignment of network reachable and telent connections

RHSA first day operation
随机推荐
GCC compilation error
BGP third experiment report
Cryptography series: detailed explanation of online certificate status protocol OCSP
静态Vxlan 配置
SQL head injection -- injection principle and essence
Processing strategy of message queue message loss and repeated message sending
Day-20 file operation, recursive copy, serialization
Customize the web service configuration file
浅谈估值模型 (二): PE指标II——PE Band
JS to convert array to tree data
Cookie
"Series after reading" my God! It's so simple to understand throttling and anti shake~
Common knowledge of one-dimensional array and two-dimensional array
Tutorial on the principle and application of database system (008) -- exercises on database related concepts
DOM parsing XML error: content is not allowed in Prolog
leetcode刷题:二叉树26(二叉搜索树中的插入操作)
On valuation model (II): PE index II - PE band
(待会删)yyds,付费搞来的学术资源,请低调使用!
Several methods of checking JS to judge empty objects
Inverted index of ES underlying principle