zoukankan      html  css  js  c++  java
  • mysql 库和表占用空间查询

    1. 查看该数据库实例下所有库大小,得到的结果是以MB为单位

    select table_schema,sum(data_length)/1024/1024 as data_length,sum(index_length)/1024/1024
    as index_length,sum(data_length+index_length)/1024/1024 as sum from information_schema.tables;

    2、查看该实例下各个库大小

    select table_schema, sum(data_length+index_length)/1024/1024 as total_mb,
    sum(data_length)/1024/1024 as data_mb, sum(index_length)/1024/1024 as index_mb,
    count(*) as tables, curdate() as today from information_schema.tables group by table_schema order by 2 desc;

    3、查看单个库的大小

    select concat(truncate(sum(data_length)/1024/1024,2),'mb') as data_size,
    concat(truncate(sum(max_data_length)/1024/1024,2),'mb') as max_data_size,
    concat(truncate(sum(data_free)/1024/1024,2),'mb') as data_free,
    concat(truncate(sum(index_length)/1024/1024,2),'mb') as index_size
    from information_schema.tables where table_schema = 'jwtnew2017';

    4、查看单个表的状态

    show table status from jwtnew2017 where name = 't_user'

    5、查看单库下所有表的状态

    use infomation_schema;
    select table_name, (data_length/1024/1024) as data_mb , (index_length/1024/1024) 
    as index_mb, ((data_length+index_length)/1024/1024) as all_mb, table_rows
    from tables where table_schema = 'mydb'
  • 相关阅读:
    Job流程:Shuffle详解
    学Python Django学得很迷茫,怎么办?-转自知乎
    URL补充
    创建多对多以及增加示例
    Day20-初识Ajax
    笔记-自己看Day20-待续
    Day20-单表中获取表单数据的3种方式
    Day19内容回顾
    一点疑惑的解释
    python os.path模块常用方法详解
  • 原文地址:https://www.cnblogs.com/jarod99/p/8724399.html
Copyright © 2011-2022 走看看