查看mysql数据库容量大小

第一种情况:查询所有数据库的总大小,方法如下:

mysql> use information_schema;

mysql> select concat(round(sum(DATA_LENGTH/1024/1024),2),‘MB‘) as data from TABLES;

+-----------+

| data      |

+-----------+

| 3052.76MB |

+-----------+

1 row in set (0.02 sec)

统计一下所有库数据量

每张表数据量=AVG_ROW_LENGTH*TABLE_ROWS+INDEX_LENGTH

SELECT

SUM(AVG_ROW_LENGTH*TABLE_ROWS+INDEX_LENGTH)/1024/1024 AS total_mb

FROM information_schema.TABLES;

统计每个库大小:

SELECT

table_schema,SUM(AVG_ROW_LENGTH*TABLE_ROWS+INDEX_LENGTH)/1024/1024 AS total_mb

FROM information_schema.TABLES group by table_schema;

第二种情况:查看指定数据库的大小,比如说:数据库test,方法如下:

mysql> use information_schema;

mysql> select concat(round(sum(DATA_LENGTH/1024/1024),2),‘MB‘) as data from TABLES where table_schema=‘test‘;

+----------+

| data     |

+----------+

| 142.84MB |

+----------+

1 row in set (0.00 sec)

1.查看所有数据库各容量大小

select

table_schema as ‘数据库‘,

sum(table_rows) as ‘记录数‘,

sum(truncate(data_length/1024/1024, 2)) as ‘数据容量(MB)‘,

sum(truncate(index_length/1024/1024, 2)) as ‘索引容量(MB)‘

from information_schema.tables

group by table_schema

order by sum(data_length) desc, sum(index_length) desc;

2.查看所有数据库各表容量大小

select

table_schema as ‘数据库‘,

table_name as ‘表名‘,

table_rows as ‘记录数‘,

truncate(data_length/1024/1024, 2) as ‘数据容量(MB)‘,

truncate(index_length/1024/1024, 2) as ‘索引容量(MB)‘

from information_schema.tables

order by data_length desc, index_length desc;

3.查看指定数据库容量大小

例:查看mysql库容量大小

select

table_schema as ‘数据库‘,

sum(table_rows) as ‘记录数‘,

sum(truncate(data_length/1024/1024, 2)) as ‘数据容量(MB)‘,

sum(truncate(index_length/1024/1024, 2)) as ‘索引容量(MB)‘

from information_schema.tables

where table_schema=‘mysql‘; 

4.查看指定数据库各表容量大小

例:查看mysql库各表容量大小

select

table_schema as ‘数据库‘,

table_name as ‘表名‘,

table_rows as ‘记录数‘,

truncate(data_length/1024/1024, 2) as ‘数据容量(MB)‘,

truncate(index_length/1024/1024, 2) as ‘索引容量(MB)‘

from information_schema.tables

where table_schema=‘mysql‘

order by data_length desc, index_length desc;

转载于https://www.cnblogs.com/--smile/p/11451238.html

原文地址:https://www.cnblogs.com/zykLove/p/12105474.html

时间: 2024-09-29 05:36:27

查看mysql数据库容量大小的相关文章

mysql数据库容量查询

1.查看所有数据库容量大小 select table_schema?as?'数据库',sum(table_rows)?as?'记录数',sum(truncate(data_length/1024/1024, 2))?as?'数据容量(MB)',sum(truncate(index_length/1024/1024, 2))?as?'索引容量(MB)'from?information_schema.tablesgroup?by?table_schemaorder?by?sum(data_lengt

POSTGRESQL 查看数据库 数据表大小

1.查看数据库大小: select pg_database_size('log_analysis'); ***(Single step mode: verify command)******************************************* select pg_database_size('log_analysis'); ***(press return to proceed or enter x and return to cancel)****************

查看mysql 数据表的真实大小空间情况

select count(*) from t1; +----------+ | count(*) | +----------+ |        5 | +----------+ SELECT table_name, data_length/1024/1024 AS 'data_length(MB)', index_length/1024/1024 AS 'index_length(MB)', (data_length + index_length)/1024/1024 AS 'total(MB

navicat查看mysql数据表记录数不断变化

在使用navicat进行数据库管理的时候,在查看表对象的时候会发现,每次刷新,数据表的记录数不断变化,尤其是大表. 对于100万的数据经常会显示九十几万,当然通过count(*)出来的数据是正确的. 非常疑惑,查了一下资料,原来和存储引擎有关.官方说明: The number of rows. Some storage engines, such as MyISAM, store the exact count. For other storage engines, such as InnoDB

查看 Mysql 数据量 (data size)

MySQL 获取数据库 data size: SELECT table_schema "Data Base Name", sum( data_length + index_length ) / 1024 / 1024 "Data Base Size in MB", sum( data_free )/ 1024 / 1024 "Free Space in MB" FROM information_schema.TABLES GROUP BY tab

查看mysql数据文件存放路径

进入mysql终端 mysql>show variables like '%datadir%'; 出来的结果即是! mysql> show variables like '%datadir%'; +---------------+------------------------+ | Variable_name | Value                  | +---------------+------------------------+ | datadir       | /usr

怎么查看 MySQL 数据文件在当前电脑的存储位置

打开数据库进行连接后,在mysql数据库模式下输入以下命令 mysql> show global variables like "%datadir%"; 不过有时候进入了该位置还是看不到数据库文件,是因为该文件夹处于隐藏状态 原文地址:https://www.cnblogs.com/lyd447113735/p/11758820.html

查看mysql表的大小(条数)

show count(1) from TABLENAME;

MySQL查看数据库表容量大小

本文介绍MySQL查看数据库表容量大小的命令语句,提供完整查询语句及实例,方便大家学习使用. 1.查看所有数据库容量大小 select table_schema as '数据库', sum(table_rows) as '记录数', sum(truncate(data_length/1024/1024, 2)) as '数据容量(MB)', sum(truncate(index_length/1024/1024, 2)) as '索引容量(MB)' from information_schema