• 查看mysql库大小,表大小,索引大小


    查看所有库的大小
    mysql> use information_schema;
    Database changed
    mysql> selectconcat(round(sum(DATA_LENGTH/1024/1024),2),'MB') as data from TABLES;
    +----------+
    | data   |
    +----------+
    | 104.21MB |
    +----------+
    1 row in set (0.11 sec)
     
    查看指定库的大小
    mysql> selectconcat(round(sum(DATA_LENGTH/1024/1024),2),'MB') as data from TABLES where table_schema='jishi';
    +---------+
    | data  |
    +---------+
    | 26.17MB |
    +---------+
    1 row in set (0.01 sec)
     
    查看指定库的指定表的大小
    mysql> selectconcat(round(sum(DATA_LENGTH/1024/1024),2),'MB') as data from TABLES where table_schema='jishi' andtable_name='a_ya';
    +--------+
    | data   |
    +--------+
    | 0.02MB |
    +--------+
    1 row in set (0.00 sec)
     
    查看指定库的索引大小
    mysql> SELECTCONCAT(ROUND(SUM(index_length)/(1024*1024), 2), ' MB') AS 'TotalIndex Size' FROM TABLES  WHERE table_schema ='jishi'; 
    +------------------+
    | Total Index Size |
    +------------------+
    | 0.94 MB  |
    +------------------+
    1 row in set (0.01 sec)
     
    查看指定库的指定表的索引大小
     
    mysql> SELECTCONCAT(ROUND(SUM(index_length)/(1024*1024), 2), ' MB') AS 'TotalIndex Size' FROM TABLES  WHERE table_schema ='test' and table_name='a_yuser'; 
    +------------------+
    | Total Index Size |
    +------------------+
    | 21.84 MB   |
    +------------------+
    1 row in set (0.00 sec)
    mysql> show create table test.a_yuserG;
    *************************** 1. row***************************
    Table: a_yuser
    Create Table: CREATE TABLE `a_yuser` (
    `email` varchar(60) NOT NULL DEFAULT'',
    `user_name` varchar(60) NOT NULL DEFAULT'',
    KEY `cc` (`email`(5)),
    KEY `ccb` (`user_name`(5)),
    KEY `ccbc`(`email`(5),`user_name`(5))
    ) ENGINE=MyISAM DEFAULT CHARSET=utf8
    1 row in set (0.00 sec)
     
    ERROR: 
    No query specified
     
    mysql> select count(*) from test.a_yuser;
    +----------+
    | count(*) |
    +----------+
    |  1073607 |
    +----------+
    1 row in set (0.00 sec)
     
    mysql> 
    查看一个库中的情况...
    mysql>  SELECTCONCAT(table_schema,'.',table_name) AS 'Table Name',CONCAT(ROUND(table_rows/1000000,4),'M') AS 'Number of Rows',CONCAT(ROUND(data_length/(1024*1024*1024),4),'G') AS 'Data Size',CONCAT(ROUND(index_length/(1024*1024*1024),4),'G') AS 'Index Size',CONCAT(ROUND((data_length+index_length)/(1024*1024*1024),4),'G')AS'Total'FROM information_schema.TABLES WHERE table_schema LIKE'test';
    +---------------+----------------+-----------+------------+---------+
    | Table Name  | Number ofRows | Data Size | Index Size | Total   |
    +---------------+----------------+-----------+------------+---------+
    | test.a_br   | 0.4625M | 0.0259G   | 0.0171G | 0.0431G |
    | test.a_skuclr | 0.7099M  | 0.0660G  | 0.0259G  |0.0919G |
    | test.a_yuser  | 1.0736M  | 0.0497G  | 0.0213G  |0.0710G |
    | test.test   | 0.0000M | 0.0000G   | 0.0000G | 0.0000G |
    +---------------+----------------+-----------+------------+---------+
    4 rows in set (0.13 sec)
  • 相关阅读:
    flash动态加载多张图片
    使用ASPJPEG添加水印的方法
    利用数据库复制技术 实现数据同步更新
    ASP.NET 2.0中发送电子邮件
    .net2.0 自定义CheckBoxList验证控件
    c#动态创建存储过程中,提示'go' 附近有语法错误解决方案
    MSDB数据库置疑状态的解决方法
    ASP.NET发送邮件_相关参数
    SQL数据库msdb置疑(急)
    SQL2000数据库脱机/只读/紧急模式 修复
  • 原文地址:https://www.cnblogs.com/hllnj2008/p/5035243.html
Copyright © 2020-2023  润新知