zl程序教程

您现在的位置是:首页 >  数据库

当前栏目

如何用SQL命令查看Mysql数据库大小

mysql数据库SQL命令 如何 查看 大小
2023-06-13 09:15:02 时间

要想知道每个数据库的大小的话,步骤如下:
1、进入information_schema数据库(存放了其他的数据库的信息)
useinformation_schema;

2、查询所有数据的大小:
selectconcat(round(sum(data_length/1024/1024),2),"MB")asdatafromtables;

3、查看指定数据库的大小:
比如查看数据库home的大小
selectconcat(round(sum(data_length/1024/1024),2),"MB")asdatafromtableswheretable_schema="home";

4、查看指定数据库的某个表的大小
比如查看数据库home中members表的大小
selectconcat(round(sum(data_length/1024/1024),2),"MB")asdatafromtableswheretable_schema="home"andtable_name="members";