(2.9)Mysql之SQL基础——索引的查看与删除
(2.9)Mysql之SQL基础——索引的查看与删除
关键词:mysql索引查看,mysql索引删除
1、索引查询(以下包括主键,唯一,普通,复合,全文,但不包括外键)
(1)按库查询
select * from information_schema.statistics where table_schema='test';
(2)按表查询
select * from information_schema.statistics where table_schema='test' and table_name = 'test103';
(3)查询
show index from table_name from db_name;
[1]show index from test102; [2]show index from test102\G --grid网格 [2]show index from test102 from test;
(4)结果
[1]NON_UNIQUE:不是唯一索引(为1则不是唯一索引,为0则是唯一索引)
[2]SEQ_IN_INDEX:索引序列,如果大于1,则必定是复合索引
[3]CARDINALITY:基数,即行数
(5)按库、表 查询索引涉及到的列
select * from information_schema.columns where table_schema= 'test' and table_name ='test104' and column_key is not null AND column_key !='';
(6)快速查找出mysql数据库中哪些表没有任何索引
通过information_schema 和 information_schema.key_column_usage 2个系统视图来查看~~
select * from information_schema.tables as t1
left join (
select distinct table_schema,table_name from information_schema.key_column_usage
) t2 on t2.table_schema=t1.table_schema and t2.table_name = t1.table_name
where t1.table_schema not in ('mysql','information_schema','performance_schema','test','sys')
AND t2.table_name is null;
2、索引的删除
(1).索引的删除
1).单列/多列/唯一索引删除:drop index 索引名 on 表名; or alter table test101 drop 索引名
2).主键索引删除: alter table test101 drop primary key;(如果有自增字段,需要先删除自增) (2).删除自增auto_increment
alter table test101 change id int;
(2.9)Mysql之SQL基础——索引的查看与删除的更多相关文章
- (2.8)Mysql之SQL基础——索引的分类与使用
(2.8)Mysql之SQL基础——索引的分类与使用 关键字:mysql索引,mysql增加索引,mysql修改索引,mysql删除索引 按逻辑分类: 1.主键索引(聚集索引)(也是唯一索引,不允许有 ...
- (2.15)Mysql之SQL基础——开发设计最佳规范
(2.15)Mysql之SQL基础——开发设计最佳规范 关键字:mysql三大范式,mysql sql开发规范 分析: show profile.mysqllsla.mysqldrmpslow.exp ...
- (2.10)Mysql之SQL基础——约束及主键重复处理
(2.10)Mysql之SQL基础——约束及主键重复处理 关键词:mysql约束,批量插入数据主键冲突 [1]查看索引: show index from table_name; [2]查看有约束的列: ...
- (2.7)Mysql之SQL基础——表的操作与查看
(2.7)Mysql之SQL基础——表的操作与查看 搜索关键字:mysql表操作,comment注释操作,mysql临时表 0.临时表 create temporary table 1.创建表(在in ...
- (2.16)Mysql之SQL基础——函数
(2.16)Mysql之SQL基础——函数 关键词:mysql函数,mysql自定义函数,mysql聚合函数,mysql字符串函数,mysql数值函数 1.自定义函数 -- (1)一般形式 creat ...
- (2.14)Mysql之SQL基础——游标
(2.14)Mysql之SQL基础——游标 关键词:Mysql游标 -- (1)定义游标 declare cur_name cursor for select * from table_name wh ...
- (2.13)Mysql之SQL基础——触发器
(2.13)Mysql之SQL基础——触发器 关键词:Mysql触发器 1.一般形式 -- 0.查看触发器[1]SHOW TRIGGERS;[2]SELECT * FROM `information_ ...
- (2.11)Mysql之SQL基础——存储过程与变量
(2.11)Mysql之SQL基础——存储过程 关键字:mysql存储过程 查看存储过程: []SELECT * FROM information_schema.ROUTINES WHERE ROUT ...
- (2.6)Mysql之SQL基础——存储引擎的查看与修改
(2.6)Mysql之SQL基础——存储引擎的查看与修改 可以使用 show engines; 查看数据库支持的所有的存储引擎: 目录: 1.数据库级别存储引擎 1.1查看现在默认的存储引擎 1.2 ...
随机推荐
- c++ ++i and i++
++i 在 i 存储的值上增加一并向使用它的表达式 ``返回" 新的, 增加后的值; 而 i++ 对 i 增加一, 但返回原来的是未增加的值. 至于++i和i++有什么区别,举个例子 1.a ...
- java web - 为什么要使用spring struts
1.软件里有很多优秀的框架,有一种类型的框架,它的特点是建立在一个现有技术的基础上,提供和现有技术一样业务功能的技术框架,这个新的技术框架比原技术更加易用,更加健壮同时功能更加强大,例如:jQuery ...
- 使用Visual Studio将C#生成DLL文件的方法
1.命令方式 打开Visual Studio安装目录下的开发人员命令提示 译 File.cs 以产生 File.exe csc File.cs 编译 File.cs 以产生 File.dll csc ...
- 单选按钮选中指定value值
$("input[name='BlogStatus'][value='" + rep.data.Status + "']").prop("checke ...
- 获取form表单数据
var modelObj = {}; var modelFieldsArray = $('#AddMusic').serializeArray(); $.each(modelFieldsArray, ...
- NYOJ467 中缀式变后缀式 【栈】
中缀式变后缀式 时间限制:1000 ms | 内存限制:65535 KB 难度:3 描写叙述 人们的日常习惯是把算术表达式写成中缀式,但对于机器来说更"习惯于"后缀式.关于算术 ...
- js 对象引用传值
1)当变量是一个对象(例如:{}或[]),使用 a = b = {} 这种形式传值的话,会变成会用传值,修改 a 时 b 会相应变化,修改 b 时 a 也一样会相应变化 var a = b = {}; ...
- Template类的使用指南【python】
转自:http://www.jb51.net/article/55011.htm
- java.lang.IncompatibleClassChangeError: Implementing class
项目中使用了quartz,但是jar包却有两个,一个1.8版本,一个2.1版本,导致jar包冲突,所以导致一启动tomcat就出现: Caused by: java.lang.Incompatible ...
- osgEarth2.8加载矢量数据描边效果
通过修改osgearth自带的agglite插件,实现矢量描边效果,可以自定义描边的颜色和宽度(单位像素) 测试文件osgearth_features.cpp #include <osg/Not ...