美文网首页
MySQL 查询索引

MySQL 查询索引

作者: 林万程 | 来源:发表于2021-08-09 17:45 被阅读0次
    SELECT a.TABLE_SCHEMA,
           a.TABLE_NAME,
           a.INDEX_NAME,
           CASE a.NON_UNIQUE WHEN 1 THEN '非唯一' ELSE '唯一' END AS 唯一性,
           group_concat(COLUMN_NAME ORDER BY SEQ_IN_INDEX) AS 列,
           group_concat(NULLABLE ORDER BY SEQ_IN_INDEX) AS 可空,
           group_concat(CARDINALITY ORDER BY SEQ_IN_INDEX) AS 散列程度,
           sum(CARDINALITY) AS 总散列程度
    FROM information_schema.statistics a
    GROUP BY a.TABLE_SCHEMA,a.TABLE_NAME,a.INDEX_NAME,a.NON_UNIQUE;
    
    SELECT column_name, count(*)
    FROM information_schema.statistics
    GROUP BY column_name
    ORDER BY count(*) DESC
    

    相关文章

      网友评论

          本文标题:MySQL 查询索引

          本文链接:https://www.haomeiwen.com/subject/haozvltx.html