美文网首页
2020-06-14--mysql

2020-06-14--mysql

作者: python小哥哥2020 | 来源:发表于2020-06-14 23:42 被阅读0次

    大家好,我是天空之城,给大家带来,mysql学习笔记---索引的基本使用
    1.了解索引及其作用
    2.熟悉常见的索引|种类
    3.掌握索引的基本使用
    4.掌握索引的实战经验

    索引是一种特殊的数据结构,类似于图书的目录,它能够极大地提升数据库的查询效率。如果没有索引,在查询数据时必须扫描表中的所有记录才能找出符合条件的记录,这种全表扫描的查询效率非常低。

    在这里插入图片描述 在这里插入图片描述 在这里插入图片描述
    show index from employee\G;
    查看索引
    create index idx_name on employee(name);
    建立索引
    explain select * from employee where name='张三';
    查看建立索引后的效果,扫描的rows变成1,建立索引之前是13,全表扫描
    
    drop index idx_name on employee;
    删除索引
    
    test_user表
    create index idx_username on test_user(username);
    
    建立了索引避免用like语句
    
    

    相关文章

      网友评论

          本文标题:2020-06-14--mysql

          本文链接:https://www.haomeiwen.com/subject/egyqxktx.html