在mysql查询库和表_查询mysql 库和表占的大小
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='表名';? ? ?修改成自己的庫名 表名
總結
以上是生活随笔為你收集整理的在mysql查询库和表_查询mysql 库和表占的大小的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: php mysql安装位置_安装php时
- 下一篇: mysql乐观锁处理超卖_通过乐观锁解决