fangyuandoit

use information_schema;
select concat(round(sum(data_length/1024/1024),2),\'MB\') as data from tables;
select concat(round(sum(data_length/1024/1024),2),\'MB\') as data from tables where table_schema=\'库名\';
select concat(round(sum(data_length/1024/1024),2),\'MB\') as data from tables where table_schema=\'库名\' and table_name=\'表名\';

 

 

解释如下:

在mysql中有一个默认的数据库 库名为`information_schema`,information_schema这张数据库保存了MySQL服务器所有数据库的信息。
 

 

use information_schema;   调用mysql自己的库分析,这个不改

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=\'库名\';   修改成自己的库名

3 查询某个库下某个表情况

select concat(round(sum(data_length/1024/1024),2),\'MB\') as data from tables where table_schema=\'库名\' and table_name=\'表名\';     修改成自己的库名 表名

 

 

 

分类:

技术点:

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-29
猜你喜欢
  • 2022-01-26
  • 2021-11-29
  • 2022-12-23
  • 2021-05-20
  • 2022-12-23
  • 2021-07-08
  • 2021-11-29
相关资源
相似解决方案