当前位置:网站首页>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 skimming: binary tree 21 (verifying binary search tree)
- Leetcode brush questions: binary tree 19 (merge binary tree)
- Leetcode skimming: binary tree 27 (delete nodes in the binary search tree)
- Design and implementation of communication protocol
- What is an esp/msr partition and how to create an esp/msr partition
- Creation and assignment of graphic objects
- 有什么类方法或是函数可以查看某个项目的Laravel版本的?
- [crawler] avoid script detection when using selenium
- BGP third experiment report
- 基于NeRF的三维内容生成
猜你喜欢
About IPSec
Preorder, inorder and postorder traversal of binary tree
Leetcode brush questions: binary tree 19 (merge binary tree)
Common knowledge of one-dimensional array and two-dimensional array
HZOJ #240. 图形打印四
.Net下极限生产力之efcore分表分库全自动化迁移CodeFirst
Day-16 set
2022a special equipment related management (boiler, pressure vessel and pressure pipeline) simulated examination question bank simulated examination platform operation
Static vxlan configuration
Day-14 common APIs
随机推荐
leetcode刷题:二叉树20(二叉搜索树中的搜索)
How to use PS link layer and shortcut keys, and how to do PS layer link
leetcode刷题:二叉树26(二叉搜索树中的插入操作)
怎样重置火狐浏览器
ACL 2022 | 序列标注的小样本NER:融合标签语义的双塔BERT模型
BGP third experiment report
2022A特种设备相关管理(锅炉压力容器压力管道)模拟考试题库模拟考试平台操作
企业级自定义表单引擎解决方案(十二)--体验代码目录结构
智云健康上市:市值150亿港元 SIG经纬与京新基金是股东
[learn microservices from 0] [03] explore the microservice architecture
【统计学习方法】学习笔记——支持向量机(下)
Simple implementation of call, bind and apply
[Q&A]AttributeError: module ‘signal‘ has no attribute ‘SIGALRM‘
Vxlan static centralized gateway
ip2long之后有什么好处?
Layer pop-up layer closing problem
图像像素读写操作
[pytorch practice] use pytorch to realize image style migration based on neural network
leetcode刷题:二叉树22(二叉搜索树的最小绝对差)
广州市召开安全生产工作会议