美文网首页
mysql-查看数据库、索引、表大小

mysql-查看数据库、索引、表大小

作者: 李哈哈_2c85 | 来源:发表于2020-09-03 10:40 被阅读0次

    2020/09/03
    mysql查看当前所有的数据库和索引大小

    select table_schema, concat(truncate(sum(data_length)/1024/1024,2),' mb') as data_size,
    concat(truncate(sum(index_length)/1024/1024,2),'mb') as index_size
    from information_schema.tables
    group by table_schema
    order by data_length desc;

    查询单独数据库大小

    SELECT
    table_schema AS 'DB Name',
    ROUND(SUM(data_length + index_length) / 1024 / 1024, 1) AS 'DB Size in MB'
    FROM
    information_schema.tables
    WHERE
    table_schema = '数据库名称'
    GROUP BY
    table_schema;

    mysql查看当前某个数据库和数据库下所有的表的大小

    select table_name, concat(truncate(data_length/1024/1024,2),' mb') as data_size,
    concat(truncate(index_length/1024/1024,2),' mb') as index_size
    from information_schema.tables where table_schema = 'ops_monitor'     #这个修改为数据库名称
    group by table_name
    order by data_length desc;

    相关文章

      网友评论

          本文标题:mysql-查看数据库、索引、表大小

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