查看数据库大小的方法:
MariaDB [mysql]> show databases;
MariaDB [mysql]> use information_schema;
查询所有数据库大小:
MariaDB [mysql]> select concat(round(sum(DATA_LENGTH/1024/1024),2),‘MB‘) as data from TABLES;
查询制定的数据库大小:
MariaDB [mysql]> select concat(round(sum(DATA_LENGTH/1024/1024),2),‘MB‘) as data from TABLES where table_schema=‘VIEWS‘;
可以看到,查询数据库大小只需要制定数据库的名称即可,如果需要查询数据库内制定表的大小,在最后添加条件即可:
MariaDB [mysql]> select concat(round(sum(DATA_LENGTH/1024/1024),2),‘MB‘) as data from TABLES where table_schema=‘VIEWS‘ and table_name=‘name‘;
原文地址:https://blog.51cto.com/smartlieo/2361643
时间: 2024-11-08 20:00:16