当前位置:网站首页>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
边栏推荐
- 图形对象的创建与赋值
- gcc 编译报错
- SQL lab 1~10 summary (subsequent continuous update)
- leetcode刷题:二叉树27(删除二叉搜索树中的节点)
- Several methods of checking JS to judge empty objects
- NGUI-UILabel
- Tutorial on the principle and application of database system (011) -- relational database
- sql-lab (54-65)
- 【统计学习方法】学习笔记——第四章:朴素贝叶斯法
- leetcode刷题:二叉树22(二叉搜索树的最小绝对差)
猜你喜欢
Static routing assignment of network reachable and telent connections
leetcode刷题:二叉树21(验证二叉搜索树)
SQL head injection -- injection principle and essence
Static vxlan configuration
浅谈估值模型 (二): PE指标II——PE Band
图像像素读写操作
How to use PS link layer and shortcut keys, and how to do PS layer link
Common knowledge of one-dimensional array and two-dimensional array
[pytorch practice] use pytorch to realize image style migration based on neural network
Vxlan static centralized gateway
随机推荐
2022聚合工艺考试题模拟考试题库及在线模拟考试
gcc 编译报错
The IDM server response shows that you do not have permission to download the solution tutorial
Vxlan 静态集中网关
What is an esp/msr partition and how to create an esp/msr partition
Day-20 file operation, recursive copy, serialization
Learning and using vscode
Day-16 set
leetcode刷题:二叉树24(二叉树的最近公共祖先)
ES底层原理之倒排索引
2022广东省安全员A证第三批(主要负责人)考试练习题及模拟考试
The left-hand side of an assignment expression may not be an optional property access. ts(2779)
SQL Lab (46~53) (continuous update later) order by injection
IPv6 experiment
Tutorial on the principle and application of database system (011) -- relational database
Solutions to cross domain problems
【深度学习】图像多标签分类任务,百度PaddleClas
Realize all, race, allsettled and any of the simple version of promise by yourself
Processing strategy of message queue message loss and repeated message sending
About IPSec