当前位置:网站首页>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
边栏推荐
- The IDM server response shows that you do not have permission to download the solution tutorial
- leetcode刷题:二叉树21(验证二叉搜索树)
- Aike AI frontier promotion (7.7)
- Simple network configuration for equipment management
- Static vxlan configuration
- 【统计学习方法】学习笔记——逻辑斯谛回归和最大熵模型
- [爬虫]使用selenium时,躲避脚本检测
- 【二叉树】删点成林
- Day-17 connection set
- 【从 0 开始学微服务】【00】课程概述
猜你喜欢
MPLS experiment
Sort out the garbage collection of JVM, and don't involve high-quality things such as performance tuning for the time being
JS to convert array to tree data
leetcode刷题:二叉树22(二叉搜索树的最小绝对差)
Experiment with a web server that configures its own content
Tutorial on the principle and application of database system (011) -- relational database
<No. 9> 1805. Number of different integers in the string (simple)
Attack and defense world - PWN learning notes
BGP actual network configuration
opencv的四个函数
随机推荐
SQL lab 21~25 summary (subsequent continuous update) (including secondary injection explanation)
NGUI-UILabel
[deep learning] image multi label classification task, Baidu paddleclas
Multi row and multi column flex layout
Day-19 IO stream
跨域问题解决方案
Typescript interface inheritance
SQL blind injection (WEB penetration)
【PyTorch实战】用PyTorch实现基于神经网络的图像风格迁移
SQL head injection -- injection principle and essence
Inverted index of ES underlying principle
[statistical learning method] learning notes - support vector machine (I)
SQL lab 11~20 summary (subsequent continuous update) contains the solution that Firefox can't catch local packages after 18 levels
解决 Server returns invalid timezone. Go to ‘Advanced’ tab and set ‘serverTimezone’ property manually
leetcode刷题:二叉树25(二叉搜索树的最近公共祖先)
2022A特种设备相关管理(锅炉压力容器压力管道)模拟考试题库模拟考试平台操作
Decrypt gd32 MCU product family, how to choose the development board?
leetcode刷题:二叉树21(验证二叉搜索树)
利用棧來實現二進制轉化為十進制
Routing strategy of multi-point republication [Huawei]