当前位置:网站首页>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
边栏推荐
- leetcode刷题:二叉树21(验证二叉搜索树)
- How to use PS link layer and shortcut keys, and how to do PS layer link
- 有什么类方法或是函数可以查看某个项目的Laravel版本的?
- 《ASP.NET Core 6框架揭秘》样章[200页/5章]
- HZOJ #236. Recursive implementation of combinatorial enumeration
- Charles: four ways to modify the input parameters or return results of the interface
- GCC compilation error
- About IPSec
- Day-16 set
- Connect to blog method, overload, recursion
猜你喜欢
Static routing assignment of network reachable and telent connections
JS to convert array to tree data
ACL 2022 | 序列标注的小样本NER:融合标签语义的双塔BERT模型
MPLS experiment
Day-14 common APIs
Static vxlan configuration
Pule frog small 5D movie equipment | 5D movie dynamic movie experience hall | VR scenic area cinema equipment
Leetcode brush question: binary tree 24 (the nearest common ancestor of binary tree)
Sorting, dichotomy
The left-hand side of an assignment expression may not be an optional property access. ts(2779)
随机推荐
The URL modes supported by ThinkPHP include four common modes, pathinfo, rewrite and compatibility modes
BGP actual network configuration
[statistical learning methods] learning notes - improvement methods
Layer pop-up layer closing problem
Airserver automatically receives multi screen projection or cross device projection
IPv6 experiment
@Resource和@Autowired的区别?
SSM框架搭建的步骤
Polymorphism, final, etc
MySQL导入SQL文件及常用命令
[crawler] avoid script detection when using selenium
【统计学习方法】学习笔记——提升方法
【二叉树】删点成林
What if does not match your user account appears when submitting the code?
visual stdio 2017关于opencv4.1的环境配置
HZOJ #240. 图形打印四
Cookie
[pytorch practice] use pytorch to realize image style migration based on neural network
3D content generation based on nerf
BGP third experiment report