zoukankan      html  css  js  c++  java
  • 7.表的索引

    汉语字典
    拼音 偏旁部首

    数据库中的索引就是类似于目录。

    select *** from t_student where senam = 'Apple';


    每一张都带一个主键索引。即通过主键的查询比其他字段要快。

    创建普通索引:
    create index 索引名 on 表名(字段名);
    create index in_a on t_studet(sphone);

    创建唯一索引: (唯一索引要求字段的值不能重复)
    create UNIQUE index 索引名 on 表名(字段);


    多列索引
    create index 索引名 on t_studet(字段1,字段2);

    explain可以展示一个查询的过程。


    explain select * from t_student where sname='Tea';

    explain select * from t_student where sphone='123123213213';

    增删的时候索引需要消耗时间,即不是索引越多越好,一般的只是在需要频繁查询的字段添加
    一个索引。
    show index from 表名: 显示当前表的所有索引
    drop index 索引名 on 表名:删除索引

    优化可查询的速度,但降低了增删的速度

  • 相关阅读:
    jq绑定on事件无效
    数字以0补全
    redis常用操作
    mysql数据操作日常
    centos端口映射
    centos7防火墙操作
    mysql5.7order by问题
    centos无法上网解决方法
    面试题
    ztree 获取子节点所有父节点的name的拼接
  • 原文地址:https://www.cnblogs.com/makalochen/p/10656593.html
Copyright © 2011-2022 走看看