• 索引


    分类

      1.单值索引:单列,一个表可以有多个单值索引

      2.唯一索引:不能重复,比如id,可以为null

      3.复合索引:多个列构成的索引

      4.主键索引:如果在创建语句设置字段的时候设置了primary key ,则默认为主键索引,严格来说,主键索引也是唯一索引,但是主键索引不能为null,这是他们的主要区别

    创建索引

      方式一:

        create 索引类型 索引名 on 表(字段)

        单值:create index password_index on shine (password);

        唯一:create unique index name_index on shine (name);

        复合:create index name_password_index on shine (name,password);

      方式二:

        alter table 表名 add 索引类型 索引名(字段);

        单值:alter table shine add index name_index (name);

        唯一:alter table shine add unique index id_index (id);

        复合:alter table shine add index name_password_index (name,password);

    删除索引:

      drop index 索引名 on 表名;

      drop index id_index on shine;

    查询索引:

      show index from 表名;

      show index from shine; 

      show index from shineG

     

    注意:

      在使用的时候可以用三种方式结尾,分别是; , g , G

      三者都代表结束的意思。g完全等同于“;”;这两个是以行来排列。G就是以列来排列,这是他们的主要区别

      比如以G结尾

      

      以;或者g结尾

      

      

    杂念太多,必然根基浅薄
  • 相关阅读:
    反向映射和写时复制
    内存分析的好blog
    minicom使用
    tee的妙用
    网络带宽
    mem analyse
    linux 应用层常用API/命令
    ubuntu 库依赖问题
    Python基础学习笔记(一:hello world)
    第7章 取消与关闭
  • 原文地址:https://www.cnblogs.com/starshine-zhp/p/12200509.html
Copyright © 2020-2023  润新知