工作中,有时候会遇到需要查看mysql中某个数据库或者某个表的大小,通过以下方法可以查询到。
下面介绍用navicat中查看方法:
1.首先进入information_schema 数据库(存放了其他的数据库的信息)
2.查看大小
(1)查看所有数据库大小
select
concat(round(
sum
(DATA_LENGTH/1024/1024),2),
'MB'
)
as
data
from
TABLES;
(2)查看指定数据库大小
select
concat(round(
sum
(DATA_LENGTH/1024/1024),2),
'MB'
)
as
data
from
TABLES
where
table_schema=
'oa'
;
(3)查看指定数据库的指定表单的大小
select
concat(round(
sum
(DATA_LENGTH/1024/1024),2),
'MB'
)
as
data
from
TABLES
where
table_schema=
'oa'
and
table_name=
'oa_user'
;
查看指定数据库指定表单的其他大小:
select concat(round(sum(DATA_LENGTH/1024/1024),2),'MB') as data_size,
concat(round(sum(MAX_DATA_LENGTH/1024/1024),2),'MB') as max_data_size,
concat(round(sum(INDEX_LENGTH/1024/1024),2),'MB') as index_size,
concat(round(sum(DATA_FREE/1024/1024),2),'MB') as data_free
from TABLES where table_schema='oa' and table_name='oa_user';