【mysql】统计库、表大小
1. 查看该数据库实例下所有库大小,得到的结果是以MB为单位
mysql> 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;
+--------------------+---------------+--------------+---------------+
| table_schema | data_length | index_length | sum |
+--------------------+---------------+--------------+---------------+
| information_schema | 2734.92757511 | 86.27539063 | 2821.20296574 |
+--------------------+---------------+--------------+---------------+
2、查看该实例下各个库大小
mysql> 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;
+--------------------+---------------+---------------+-------------+--------+------------+
| table_schema | total_mb | data_mb | index_mb | tables | today |
+--------------------+---------------+---------------+-------------+--------+------------+
| data_1234567890 | 2820.59610939 | 2734.39689064 | 86.19921875 | 65 | 2015-11-02 |
| mysql | 0.60579967 | 0.53744030 | 0.06835938 | 14 | 2015-11-02 |
| information_schema | 0.00781250 | 0.00000000 | 0.00781250 | 35 | 2015-11-02 |
+--------------------+---------------+---------------+-------------+--------+------------+
3、查看单个库的大小
mysql> 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 = 'erongtu_tyb2014';
+-----------+------------------+-----------+------------+
| data_size | max_data_size | data_free | index_size |
+-----------+------------------+-----------+------------+
| 2734.40mb | 83483426815.99mb | 14.06mb | 86.19mb |
+-----------+------------------+-----------+------------+
4、查看单个表的状态
mysql> show table status from data_1234567890 where name = 'data_1234567890_ss' \G
*************************** 1. row ***************************
Name: data_1234567890_ss
Engine: InnoDB
Version: 10
Row_format: Compact
Rows: 840065
Avg_row_length: 477
Data_length: 401473536
Max_data_length: 0
Index_length: 0
Data_free: 6291456
Auto_increment: 882251
Create_time: 2015-09-07 17:24:18
Update_time: NULL
Check_time: NULL
Collation: utf8_general_ci
Checksum: NULL
Create_options:
Comment:
1 row in set (0.00 sec)
5、查看单库下所有表的状态
mysql> 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 information_schema.tables where table_schema = 'data_1234567890';
+---------------------------+---------------+-------------+---------------+------------+
| table_name | data_mb | index_mb | all_mb | table_rows |
+---------------------------+---------------+-------------+---------------+------------+
| ss_daccount | 0.23437500 | 0.10937500 | 0.34375000 | 4481 |
| ss_daccount_log | 2.48262787 | 0.58496094 | 3.06758881 | 27248 |
| ss_daccount_type | 0.00025558 | 0.00195313 | 0.00220871 | 8 |
| ss_daccountlog | 221.61502457 | 22.66113281 | 244.27615738 | 1045462 |
| ss_dactives | 0.00178146 | 0.00195313 | 0.00373459 | 7 |
| ss_dadmin | 0.00268173 | 0.00195313 | 0.00463486 | 19 |
| ss_dadmin_log | 0.36599731 | 0.05175781 | 0.41775513 | 5191 |
| ss_dadmin_nav | 0.01562500 | 0.00000000 | 0.01562500 | 46 |
| ss_dadmin_role | 0.01562500 | 0.01562500 | 0.03125000 | 5 |
| ss_dadvertisement | 0.07812500 | 0.00000000 | 0.07812500 | 486 |
| ss_dadvertisement_click | 382.87500000 | 0.00000000 | 382.87500000 | 1023350 |
| ss_dadvertisement_content | 0.10937500 | 0.01562500 | 0.12500000 | 105 |
| ss_dapplication | 3.23010635 | 0.02441406 | 3.25452042 | 1859 |
| ss_dapplication_bak | 2.25843048 | 0.01269531 | 2.27112579 | 738 |
| ss_dapplication_comment | 0.88685226 | 0.05566406 | 0.94251633 | 5454 |
| ss_dapplication_material | 0.00187683 | 0.00195313 | 0.00382996 | 16 |
| ss_dapplication_user | 0.90316010 | 0.10839844 | 1.01155853 | 8861 |
| ss_darea | 1.05803299 | 0.88769531 | 1.94572830 | 45051 |
| ss_dauthentication | 0.00072861 | 0.00195313 | 0.00268173 | 13 |
| ss_dbbs_relatedlink | 0.01562500 | 0.00000000 | 0.01562500 | 12 |
| ss_dborrow | 0.04732895 | 0.00390625 | 0.05123520 | 153 |
| ss_dborrow_collection | 27.61576080 | 13.99023438 | 41.60599518 | 221169 |
| ss_dborrow_lz | 0.00000000 | 0.00097656 | 0.00097656 | 0 |
| ss_dborrow_tender | 24.62931824 | 18.27050781 | 42.89982605 | 147411 |
| ss_dcash | 6.40177155 | 1.97949219 | 8.38126373 | 42807 |
| ss_dcp_block | 0.04687500 | 0.01562500 | 0.06250000 | 37 |
| ss_dcp_item | 0.09375000 | 0.00000000 | 0.09375000 | 134 |
| ss_dedu_member | 0.01562500 | 0.00000000 | 0.01562500 | 13 |
| ss_dinfo_article | 78.76256561 | 1.19433594 | 79.95690155 | 10038 |
| ss_dinfo_channel | 0.01562500 | 0.00000000 | 0.01562500 | 56 |
| ss_dinfo_comment | 0.32812500 | 0.00000000 | 0.32812500 | 1206 |
| ss_dinfo_nav | 0.01562500 | 0.00000000 | 0.01562500 | 27 |
| ss_dinfo_p2pdata | 0.90237427 | 0.29101563 | 1.19338989 | 29569 |
| ss_dinfo_p2pdata_0 | 0.04687500 | 0.00000000 | 0.04687500 | 275 |
| ss_dinfo_photo | 0.23437500 | 0.00000000 | 0.23437500 | 71 |
| ss_dinfo_project | 0.06250000 | 0.00000000 | 0.06250000 | 67 |
| ss_dinfo_seekdata | 35.53404236 | 0.64062500 | 36.17466736 | 5002 |
| ss_dinfo_tagname | 0.01562500 | 0.00000000 | 0.01562500 | 18 |
| ss_dinfo_testinfo | 0.01562500 | 0.00000000 | 0.01562500 | 21 |
| ss_dinfo_video | 0.91273117 | 0.00781250 | 0.92054367 | 207 |
| ss_djiao | 0.01562500 | 0.00000000 | 0.01562500 | 3 |
| ss_dliberty | 3.79615784 | 0.27734375 | 4.07350159 | 23108 |
| ss_dliberty_item | 3.08350754 | 1.24414063 | 4.32764816 | 51113 |
| ss_dloan | 0.00000000 | 0.00390625 | 0.00390625 | 0 |
| ss_dmarke | 0.01973343 | 0.00390625 | 0.02363968 | 125 |
| ss_dmedal | 0.00000000 | 0.00097656 | 0.00097656 | 0 |
| ss_dmember_comment | 0.00995636 | 0.00195313 | 0.01190948 | 87 |
| ss_dmembers | 6.73762321 | 0.33203125 | 7.06965446 | 30717 |
| ss_dmembers_identity | 0.10503769 | 0.00976563 | 0.11480331 | 784 |
| ss_dnewyear | 0.00308609 | 0.00195313 | 0.00503922 | 32 |
| ss_drecharge | 29.13045883 | 10.23925781 | 39.36971664 | 221220 |
| ss_dsalon_click | 0.00586700 | 0.00195313 | 0.00782013 | 31 |
| ss_dsalon_comment | 0.07812500 | 0.00000000 | 0.07812500 | 213 |
| ss_dsalon_content | 0.14062500 | 0.00000000 | 0.14062500 | 653 |
| ss_dsalon_ticket | 0.00093079 | 0.00195313 | 0.00288391 | 20 |
| ss_dsignin | 0.37500000 | 0.00000000 | 0.37500000 | 7177 |
| ss_dtemplate | 0.15721893 | 0.03808594 | 0.19530487 | 2838 |
| ss_dwd_answers | 2.51562500 | 0.00000000 | 2.51562500 | 5420 |
| ss_dwd_classify | 0.01562500 | 0.00000000 | 0.01562500 | 12 |
| ss_dwd_collection | 0.01562500 | 0.00000000 | 0.01562500 | 2 |
| ss_dwd_questions | 1.51562500 | 0.00000000 | 1.51562500 | 3614 |
| ss_dwget | 1894.69999695 | 13.02929688 | 1907.72929382 | 1187574 |
| ss_dzhuanti_bolanhui | 0.00419235 | 0.00195313 | 0.00614548 | 20 |
| click | 0.00000000 | 0.00097656 | 0.00097656 | 0 |
| ss_account | 0.14062500 | 0.07812500 | 0.21875000 | 1871 |
+---------------------------+---------------+-------------+---------------+------------+
【mysql】统计库、表大小的更多相关文章
- MySQL统计库表大小
统计每个库每个表的大小是数据治理的其中最简单的一个要求,本文将从抽样统计结果及精确统计结果两方面来统计MySQL的每个库每个表的数据量情况. 1.统计预估数据量 mysql数据字典库informati ...
- MySQL查看库表的大小
MySQL数据库空间使用情况查询 如果想知道MySQL数据库中每个表占用的空间.表记录的行数的话,可以打开MySQL的 information_schema 数据库.在该库中有一个 TABLES 表, ...
- MySQL查看某库表大小及锁表情况
查询所有数据库占用磁盘空间大小的SQL语句: 语句如下: select TABLE_SCHEMA, concat(truncate(sum(data_length)/1024/1024,2),' MB ...
- MySQL基本库表管理
基本管理指令 mysql登陆 第一种 [root@wei ~]# mysql -u root -p 第二种(带参输入) [root@wei ~]# mysql -uroot -proot 注意:每个命 ...
- mysql: 查看某库表大小
查询所有数据库占用磁盘空间大小的SQL语句: 语句如下 1 2 3 4 5 select TABLE_SCHEMA, concat(truncate(sum(data_length)/1024/102 ...
- mysql查看某库表大小
查询所有数据库占用磁盘空间大小的SQL语句: 语句如下 select TABLE_SCHEMA, concat(truncate(sum(data_length)/1024/1024,2),' MB' ...
- mysql统计库下所有表数据行数
一.执行下面sql select concat( 'select "', TABLE_name, '", count(*) from ', TABLE_SCHEMA, '.', T ...
- mysql 之库, 表的简易操作
一. 库的操作 1.创建数据库 创建数据库: create database 库名 charset utf8; charset uft8 可选项 1.2 数据库命名规范: 可以由字母.数字.下划 ...
- MySQL之库表详细操作
一 库操作 1.创建数据库 1.1 语法 CREATE DATABASE 数据库名 charset utf8; 1.2 数据库命名规则 可以由字母.数字.下划线.@.#.$ 区分大小写 唯一性 不能使 ...
- MySQL的库表详细操作
MySQL数据库 本节目录 一 库操作 二 表操作 三 行操作 一 库操作 1.创建数据库 1.1 语法 CREATE DATABASE 数据库名 charset utf8; 1.2 数据库命名规则 ...
随机推荐
- IOS开发UI基础UIPageControl的属性
UIPageControl 常见属性: • numberOfPages // 设置有多少页 默认为0 [pageControl setNumberOfPages:kImageCount]; • ...
- jQuery点缩略图显示大图片
2015年繁忙的一月份,无更多时间去学习ASP.NET MVC程序,二月份又是中国的新年,长达半个月的假期,望回到老家中,在无电脑无网络的日子里,能有更多时间陪伴年迈的父母亲. 今天学习jQuery的 ...
- Winform开发框架之权限管理系统改进的经验总结(2)-用户选择界面的设计
在上篇总结随笔<Winform开发框架之权限管理系统改进的经验总结(1)-TreeListLookupEdit控件的使用>介绍了权限管理模块的用户管理部分,其中主要介绍了其中的用户所属公司 ...
- 介绍两种风格的URL
两种风格的“动态资源”——统一资源定位符(Uniform Resource Lactor,URL) 当前互联网上主要有两种主要风格的URL: 第一种直接在URL中知名文件(比如xxx.php,xxx. ...
- VS "15" 预览 5 中 VB 15 新增的功能
VS "15" 预览 5 给 VB 带来了更新.这次的更新内容有3个: * 值元组 ValueTuple这个功能能把一组计算结果成组返回.为了使用这个功能,我们要安装 System ...
- floyd离散,最小环
Description 杭州有N个景区,景区之间有一些双向的路来连接,现在8600想找一条旅游路线,这个路线从A点出发并且最后回到A点,假设经过的路线为V1,V2,....VK,V1,那么必须满足K& ...
- Servlet-中文乱码
背景 从Tomcat5.x开始,GET,POST方法提交信息,Tomcat采用不同的方式来处理编码. 对于GET请求,Tomcat不会考虑使用request.setCharacterEncoding( ...
- Asp.net发布的CheckList
Asp.net Web 应用程序正式发布前,我们还是做一些检查,所以需要这个CheckList,如下图今天的Asp.net 已演化这样的了: 但不管是什么组件,目前的Web最终还得通过H ...
- Python迭代器:捕获Generator的返回值
但是用for循环调用generator时,发现拿不到generator的return语句的返回值.如果想要拿到返回值,必须捕获StopIteration错误,返回值包含在StopIteration的v ...
- mysql awr v1.0.2发布
改进说明: 1.新增监控Mysql实例通过web控制台http://ip:port/hosts.html进行,无需更改mysql-jdbc.properties配置文件和spring-servlet. ...