zoukankan      html  css  js  c++  java
  • MySQL索引

    一. 索引介绍

      数据库中专门用于帮助用户快速查找数据的一种数据结构.

      类似于字典中的目录,查找字典内容时可以根据目录查找到数据的存放位置,然后直接获取.

      无索引查找需要从开始向后一条一条查询.

      创建索引查找的本质,即使创建额外的文件(使用某种格式存储,查询的时候先去额外的文件定好位置;然后再去原始的表中直接查询.)

    二. 索引作用

      约束和加速查找

      额外的文件保存特殊的数据结构

      查询快,但是插入更新仍然慢

      创建索引后,必须命中索引才有效

    三. 常见的几种索引

      1. 普通索引

      2. 唯一索引

      3. 主键索引

      4. 联合索引

        ①. 联合主键索引

        ②. 联合唯一索引

        ③. 联合普通索引

    四. 索引的创建,删除,查看

      1. 普通索引  作用 : 仅有一个加速查找

        增加 : cerate index 索引的名字 on 表名(列名)

        删除 : drop index 索引的名字 on 表名

        查看 : show index from 字段名

      2. 唯一索引  作用 : 加速查找和唯一约束(可以含有null)

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

        删除 : drop index 索引名 on 表名

      3. 主键索引  作用 : 加速查找和唯一约束(可以含有null)

        增加 : alter table 表名 add primary key (字段名)

        删除 : alter table 表名 drop primary key

      4. 组合索引  作用 : 将n个列组合成一个索引

        增加 : create index 索引名 on 表名(字段名1,字段名2)

  • 相关阅读:
    Leetcode.11 Container with Most Water
    Leetcode.19 Remove Nth Node From End of List
    Leetcode23. Merge K sorted List
    leetcode287. Find the duplicate Number
    LeetCode234. Palindrome Linked List
    leetcode.142 LinkedList Cycle II
    UINavigationController
    UITableView的性能优化1
    iOS触摸事件
    UITableView的性能优化
  • 原文地址:https://www.cnblogs.com/dong-/p/9703847.html
Copyright © 2011-2022 走看看