• Mysql-索引


    index----索引(普通索引创建)
    
    ---------------例 show index from 表 (查看表的索引)
    
    ---------------例 create index 索引名 on 表(列名)  (创建普通索引)
    
    ---------------例 drop 索引名 on 表;(删除普通索引)
    
    create table in1(
        nid int not null auto_increment primary key,
        name varchar(32) not null,
        email varchar(64) not null,
        extra text,
        index ix_name (name)
    )
    普通索引
    unique----唯一的(唯一索引创建)
    
    ---------------例 create unique index 索引名 on 表名(列名);(创建唯一索引)
    
    ---------------例 drop unique index 索引名 on 表名;(删除唯一索引)
    
    create table in1(
        nid int not null auto_increment primary key,
        name varchar(32) not null,
        email varchar(64) not null,
        extra text,
        unique ix_name (name)
    )
    唯一索引
    ---------------例 alter table 表 add primary key(列);(创建主键索引)
    
    ---------------例 alter table 表 drop primary key;(删除主键索引)
    
    ---------------例 alter table 表名  modify  列名 int, drop primary key;(删除主键索引)
    
    
    create table in1(
        nid int not null auto_increment primary key,
        name varchar(32) not null,
        email varchar(64) not null,
        extra text,
        index ix_name (name)
    )
    
    OR
    
    create table in1(
        nid int not null auto_increment,
        name varchar(32) not null,
        email varchar(64) not null,
        extra text,
        primary key(ni1),
        index ix_name (name)
    )
    主键索引
    index(列1,列2) ---两列组合 --- 最左前缀
    
    ---------------例 create index ix_name_email on in3(name,email);(创建组合索引)
    
    ---------------例 select * from 表 where 列1 = 值   (走索引)
    
    ---------------例 select * from 表 where 列1 = 值 and 列2 = 值  (走索引)
    
    ---------------例 select * from 表 where 列2 = 值 (不走索引)
    
    
    create table in3(
        nid int not null auto_increment primary key,
        name varchar(32) not null,
        email varchar(64) not null,
        extra text
    )
    组合索引
    explain 查看执行过程
    
    const 不变的  通过explain查看执行过程的时候 type 的类型 是最快的,
    
    ---------------例 explain select * from 表 where 列=值;
    其他
  • 相关阅读:
    CodeceptJS学习笔记-高级用法03-tag
    CodeceptJS学习笔记-高级用法02-数据驱动测试
    CodeceptJS学习笔记-高级用法01-多次运行片状测试
    CodeceptJS学习笔记-入门05-生成HTML测试报告
    CodeceptJS学习笔记-入门04-CodeceptUI 安装和启动
    CodeceptJS学习笔记-入门03-使用nodejs运行
    CodeceptJS学习笔记-入门02
    Java线上问题排查
    rabbitmq分布式事务解决方案
    Java架构技术体系
  • 原文地址:https://www.cnblogs.com/cloniu/p/6401662.html
Copyright © 2020-2023  润新知