当前位置:网站首页>How does MySQL create, delete, and view indexes?
How does MySQL create, delete, and view indexes?
2022-07-07 12:51:00 【Full stack programmer webmaster】
mysql It is an open source database with a wide range of applications .mysql The index inside can use pointers , Can greatly improve the query efficiency . Especially when the amount of data is very large , When a query involves multiple tables , Using indexes can often speed up queries thousands of times . that , How to create an index ?
- First step , Create a table , The structure is as follows :create table t (id int unsigned not null,name varchar(20) not null default ‘-‘);
- The second step , Add index , Second, the index is divided into several categories , General index , primary key , And unique index , The steps are shown in the figure : Number in the figure 123 It corresponds to the general index , primary key , And unique index alter table Table name add index/unique/primary key ( Index name );
- The third step , There is already an index in the table , How to check ? With these two commands :show index from table; or show keys from table; Pictured : show index from Table name ; show keys from Table name ;
- Step four , Sometimes there are too many indexes , It will cause the performance of adding, deleting, modifying and checking , So you can create it and delete it , The order is as follows : drop index Index name on Table name ; DROP INDEX index_name ON talbe_name; ALTER TABLE table_name DROP INDEX index_name; ALTER TABLE table_name DROP PRIMARY KEY;
- Step five , When deleting the index above , There was a mistake , Say that the index name cannot be found , Because it was deleted the first time , therefore , This index name no longer exists , Pictured
- Step six , Query the index again , Whether the deletion was successful , Repeat the command in step 3 , The result is shown in Fig. , The description has been deleted
Publisher : Full stack programmer stack length , Reprint please indicate the source :https://javaforall.cn/113449.html Link to the original text :https://javaforall.cn
边栏推荐
- Master formula. (used to calculate the time complexity of recursion.)
- 【PyTorch实战】用RNN写诗
- Leetcode brush question: binary tree 24 (the nearest common ancestor of binary tree)
- ip2long之后有什么好处?
- Day-19 IO stream
- Day-14 common APIs
- Pule frog small 5D movie equipment | 5D movie dynamic movie experience hall | VR scenic area cinema equipment
- How to use PS link layer and shortcut keys, and how to do PS layer link
- 【PyTorch实战】图像描述——让神经网络看图讲故事
- On valuation model (II): PE index II - PE band
猜你喜欢

【统计学习方法】学习笔记——支持向量机(下)

Leetcode brush question: binary tree 24 (the nearest common ancestor of binary tree)

visual stdio 2017关于opencv4.1的环境配置

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

Master公式。(用于计算递归的时间复杂度。)

明星企业普渡科技大裁员:曾募资超10亿 腾讯红杉是股东

Dialogue with Wang Wenyu, co-founder of ppio: integrate edge computing resources and explore more audio and video service scenarios

The IDM server response shows that you do not have permission to download the solution tutorial
![Routing strategy of multi-point republication [Huawei]](/img/5c/2e3b739ce7199f0d2a4ddd7c3856fc.jpg)
Routing strategy of multi-point republication [Huawei]

IPv6 experiment
随机推荐
How to use PS link layer and shortcut keys, and how to do PS layer link
Error in compiling libssl
Image pixel read / write operation
Day-15 common APIs and exception mechanisms
leetcode刷题:二叉树20(二叉搜索树中的搜索)
谷歌浏览器如何重置?谷歌浏览器恢复默认设置?
爱可可AI前沿推介(7.7)
Aike AI frontier promotion (7.7)
基于NeRF的三维内容生成
ip2long与long2IP 分析
聊聊Redis缓存4种集群方案、及优缺点对比
Customize the web service configuration file
[statistical learning methods] learning notes - improvement methods
leetcode刷题:二叉树23(二叉搜索树中的众数)
【PyTorch实战】图像描述——让神经网络看图讲故事
Day-19 IO stream
非分区表转换成分区表以及注意事项
Leetcode skimming: binary tree 25 (the nearest common ancestor of binary search tree)
The URL modes supported by ThinkPHP include four common modes, pathinfo, rewrite and compatibility modes
2022聚合工艺考试题模拟考试题库及在线模拟考试