zoukankan      html  css  js  c++  java
  • mysql索引创建 删除 查看 检测

            小编今天稍微学习了下mysql 索引的相关知识 

    1> 创建索引

        altert table 表名 add unique(列);           //创建唯一索引
    
        altert table 表名 add index  索引名(列);  //创建普通索引
    
        altert table 表名 add primary key(列);   //创建主键索引
    
        alter  table  表名 add fulltext(列1,列2);  //创建全文索引
    
        create index 索引名 on  表名(列);      
    
        create unique index 索引名 on 表名(列);   
    
    create 不能创建primary key 索引

    2> 删除索引

        Drop index 索引名 on 表名
    
        alter table 表名 drop index 索引名
    
        alter table 表名 drop primary key

    3> 查看索引

        show index from 表名
    
        show keys from 表名

    4> 检测索引

     explain select * from news where news_id=7

    下面是查询的效果 

    5> index,primary key,unique,fulltext 区别

    PRIMARY     主键,一个表中只能有一个主键,  该键值不能为   NULL   ,不能重复 
    
    UNIQUE     唯一键(或称   第二辅助键),一个表中可以有多个 该键值不能重复,但是可以有多个记录值为   NULL 
    
    INDEX        普通的索引 
    
    FULLTEXT    全文索引

     先说到这里啊 。。还有后续内容

     

  • 相关阅读:
    css-断网图片加载失败,图片表情与文字对齐
    工作中遇到一些不会写的样式
    基础知识题目
    前端基础知识html css
    js match
    jquery.extend()与jquery.fn.extend()的区别
    js apply 与 call
    jdk安装
    js数组操作各种方法
    js获取日期
  • 原文地址:https://www.cnblogs.com/wlgaojin/p/2740497.html
Copyright © 2011-2022 走看看