zoukankan      html  css  js  c++  java
  • 索引

    分类

      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结尾

      

      

    杂念太多,必然根基浅薄
  • 相关阅读:
    mysql免安装使用(win7 64位系统)
    [NOIP2011]瑞士轮
    [NOIP2011]数的划分
    [洛谷2994]超级弹珠
    并查集
    [codevs1073]家族
    快速幂
    [NOI2002]银河英雄传说
    [NOIP2007]矩阵取数游戏
    [洛谷2415]集合求和
  • 原文地址:https://www.cnblogs.com/starshine-zhp/p/12200509.html
Copyright © 2011-2022 走看看