mysql怎么查看数据库中表的大小

mysql怎么查看数据库中表的大小,第1张

1、查询整个mysql数据库,整个库的大小;单位转换为MB。

select concat(round(sum(DATA_LENGTH/1024/1024),2),'MB') as data  from information_schema.TABLES

2、查询mysql数据库,某个库的大小;

select concat(round(sum(DATA_LENGTH/1024/1024),2),'MB') as data

from information_schema.TABLES

where table_schema = 'testdb'

3、查看库中某个表的大小;

select concat(round(sum(DATA_LENGTH/1024/1024),2),'MB') as data

from information_schema.TABLES

where table_schema = 'testdb'

 and table_name = 'test_a'

4、查看mysql库中,test开头的表,所有存储大小;

select concat(round(sum(DATA_LENGTH/1024/1024),2),'MB') as data

from information_schema.TABLES

where table_schema = 'testdb'

 and table_name like 'test%'

1、进入information_schema

数据库(存放了其他的数据库的信息)

use

information_schema

2、查询所有数据的大小:

select

concat(round(sum(data_length/1024/1024),2),'MB')

as

data

from

tables

3、查看指定数据库的大小:

比如查看数据库home的大小

select

concat(round(sum(data_length/1024/1024),2),'MB')

as

data

from

tables

where

table_schema='home'

4、查看指定数据库的某个表的大小

比如查看数据库home中

members

表的大小

select

concat(round(sum(data_length/1024/1024),2),'MB')

as

data

from

tables

where

table_schema='home'

and

table_name='members'

1.查看mysql数据库大小

SELECT

sum(DATA_LENGTH)+sum(INDEX_LENGTH)

FROM

information_schema.TABLES

where

TABLE_SCHEMA='数据库名'

得到的结果是以字节为单位,除1024为K,除1048576(=1024*1024)为M。

2.查看表的最后mysql修改时间

select

TABLE_NAME,UPDATE_TIME

from

INFORMATION_SCHEMA.tables

where

TABLE_SCHEMA='数据库名'

可以通过查看数据库中表的mysql修改时间,来确定mysql数据库是否已经长期不再使用。


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/sjk/10662794.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-10
下一篇 2023-05-10

发表评论

登录后才能评论

评论列表(0条)

保存