Navigation

    BAGA.OL

    • Register
    • Login
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups

    数据库索引

    博客
    数据库索引 mysql
    1
    1
    672
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • lichade
      lichade last edited by lichade

      一. 索引结构

      BTree索引、Hash索引、FullText索引

      二. 索引类型

      普通索引、唯一索引、复合索引

      唯一索引:唯一索引要求字段中不会出现重复数据。

      复合索引:将多个字段组合起来作为索引,必须使用到该索引中的第一个字段作为条件时才能保证系统使用该索引,否则该索引将不会被使用。

      三.索引操作

      建立索引:

       create index 索引名 on 表名(索引字段名)
      

      建立唯一索引:

      create unique index 索引名 on 表名(索引字段名)
      

      建立复合索引:

      create index 索引名 on 表名(索引字段名1,索引字段名2...)
      

      查看表中索引:

      show index from 表名
      

      删除索引:

      drop index 索引名 on 表名
      

      查看索引是否命中:

      Mysql:当结果的type为 index时索引命中

      explain +sql语句
      
      1 Reply Last reply Reply Quote
      • First post
        Last post