MySQL 如何查看表和数据库索引 您所在的位置:网站首页 mysql怎么看表里面的内容 MySQL 如何查看表和数据库索引

MySQL 如何查看表和数据库索引

2023-10-16 20:19| 来源: 网络整理| 查看: 265

目录

1、问题引入

2、查看一张指定表的索引信息

2.1 、查看指定数据库之中某一张表名的索引信息

2.2、查询某个数据库(table_schema)的全部表索引,可以从INFORMATION_SCHEMA架构中的STATISTICS表中获取索引信息

3、查看一台主机所有数据库的所有索引信息,则可以通过INFORMATION_SCHEMA查看​

4、获取指定数据库中索引的编号以及每个表的索引名​

5、查询出只包含索引的结果集

1、问题引入

        MySQL数据库之中,如何查看一个数据库是否有索引,有哪些索引?又如何查看一张指定的数据表的索引信息呢?

2、查看一张指定表的索引信息 2.1 、查看指定数据库之中某一张表名的索引信息 show index from tablename; 2.2、查询某个数据库(table_schema)的全部表索引,可以从INFORMATION_SCHEMA架构中的STATISTICS表中获取索引信息 select distinct table_name, index_name from information_schema.statistics where table_schema = 'pay(数据库名称)'; 3、查看一台主机所有数据库的所有索引信息,则可以通过INFORMATION_SCHEMA查看 use information_schema; select * from statistics;

4、获取指定数据库中索引的编号以及每个表的索引名 select table_name, count(1) index_count, group_concat(distinct(index_name) separator ',\n ') indexes from information_schema.statistics where table_schema = 'pay' and index_name != 'primary' group by table_name order by count(1) desc;

5、查询出只包含索引的结果集 select distinct s.* from information_schema.statistics s left outer join information_schema.table_constraints t on t.table_schema = s.table_schema and t.table_name = s.table_name and s.index_name = t.constraint_name where 0 = 0 and t.constraint_name is null and s.table_schema = 'pay';



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有