当前位置:网站首页>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
边栏推荐
- 【二叉树】删点成林
- ICLR 2022 | 基于对抗自注意力机制的预训练语言模型
- Static routing assignment of network reachable and telent connections
- 如何将 @Transactional 事务注解运用到炉火纯青?
- 利用栈来实现二进制转化为十进制
- Design and implementation of communication protocol
- 【统计学习方法】学习笔记——逻辑斯谛回归和最大熵模型
- ACL 2022 | small sample ner of sequence annotation: dual tower Bert model integrating tag semantics
- SSM框架搭建的步骤
- Customize the web service configuration file
猜你喜欢

【统计学习方法】学习笔记——第五章:决策树
![[statistical learning method] learning notes - support vector machine (Part 2)](/img/bc/bb4f809ff434fabc10f8e97f592fa7.png)
[statistical learning method] learning notes - support vector machine (Part 2)

Talk about four cluster schemes of redis cache, and their advantages and disadvantages
![[pytorch practice] write poetry with RNN](/img/91/a6d3f348ff099b7c44eb185921b1b6.png)
[pytorch practice] write poetry with RNN

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

leetcode刷题:二叉树23(二叉搜索树中的众数)

Financial data acquisition (III) when a crawler encounters a web page that needs to scroll with the mouse wheel to refresh the data (nanny level tutorial)

Aike AI frontier promotion (7.7)

2022a special equipment related management (boiler, pressure vessel and pressure pipeline) simulated examination question bank simulated examination platform operation

About IPSec
随机推荐
On valuation model (II): PE index II - PE band
2022聚合工艺考试题模拟考试题库及在线模拟考试
Master公式。(用于计算递归的时间复杂度。)
HZOJ #236. Recursive implementation of combinatorial enumeration
Find ID value MySQL in string
[statistical learning methods] learning notes - Chapter 5: Decision Tree
Four functions of opencv
What is an esp/msr partition and how to create an esp/msr partition
[statistical learning method] learning notes - support vector machine (Part 2)
Aike AI frontier promotion (7.7)
@Resource和@Autowired的区别?
Routing strategy of multi-point republication [Huawei]
Financial data acquisition (III) when a crawler encounters a web page that needs to scroll with the mouse wheel to refresh the data (nanny level tutorial)
Utiliser la pile pour convertir le binaire en décimal
Leetcode brush question: binary tree 24 (the nearest common ancestor of binary tree)
【从 0 开始学微服务】【01】什么是微服务
Layer pop-up layer closing problem
【统计学习方法】学习笔记——逻辑斯谛回归和最大熵模型
ACL 2022 | small sample ner of sequence annotation: dual tower Bert model integrating tag semantics
leetcode刷题:二叉树23(二叉搜索树中的众数)