MySQL查看數(shù)據(jù)庫表容量大小的方法示例
本文介紹MySQL查看數(shù)據(jù)庫表容量大小的命令語句,提供完整查詢語句及實例,方便大家學(xué)習(xí)使用。
1.查看所有數(shù)據(jù)庫容量大小
select table_schema as '數(shù)據(jù)庫', sum(table_rows) as '記錄數(shù)', sum(truncate(data_length/1024/1024, 2)) as '數(shù)據(jù)容量(MB)', sum(truncate(index_length/1024/1024, 2)) as '索引容量(MB)' from information_schema.tables group by table_schema order by sum(data_length) desc, sum(index_length) desc;
2.查看所有數(shù)據(jù)庫各表容量大小
select table_schema as '數(shù)據(jù)庫', table_name as '表名', table_rows as '記錄數(shù)', truncate(data_length/1024/1024, 2) as '數(shù)據(jù)容量(MB)', truncate(index_length/1024/1024, 2) as '索引容量(MB)' from information_schema.tables order by data_length desc, index_length desc;
3.查看指定數(shù)據(jù)庫容量大小
例:查看mysql庫容量大小
select table_schema as '數(shù)據(jù)庫', sum(table_rows) as '記錄數(shù)', sum(truncate(data_length/1024/1024, 2)) as '數(shù)據(jù)容量(MB)', sum(truncate(index_length/1024/1024, 2)) as '索引容量(MB)' from information_schema.tables where table_schema='mysql';
4.查看指定數(shù)據(jù)庫各表容量大小
例:查看mysql庫各表容量大小
select table_schema as '數(shù)據(jù)庫', table_name as '表名', table_rows as '記錄數(shù)', truncate(data_length/1024/1024, 2) as '數(shù)據(jù)容量(MB)', truncate(index_length/1024/1024, 2) as '索引容量(MB)' from information_schema.tables where table_schema='mysql' order by data_length desc, index_length desc;
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
GDB調(diào)試Mysql實戰(zhàn)之源碼編譯安裝
今天小編就為大家分享一篇關(guān)于GDB調(diào)試Mysql實戰(zhàn)之源碼編譯安裝,小編覺得內(nèi)容挺不錯的,現(xiàn)在分享給大家,具有很好的參考價值,需要的朋友一起跟隨小編來看看吧2019-02-02Mysql BinLog存儲機制與數(shù)據(jù)恢復(fù)方式
這篇文章主要介紹了Mysql BinLog存儲機制與數(shù)據(jù)恢復(fù)方式,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教2024-06-06MySQL轉(zhuǎn)換Oracle的需要注意的七個事項
有很多應(yīng)用項目, 剛起步的時候用MySQL數(shù)據(jù)庫基本上能實現(xiàn)各種功能需求,隨著應(yīng)用用戶的增多,數(shù)據(jù)量的增加,MySQL漸漸地出現(xiàn)不堪重負的情況:連接很慢甚至宕機,于是就有MySQL轉(zhuǎn)換Oracle的需求,應(yīng)用程序也要相應(yīng)做一些修改。2010-12-12MySQL Limit性能優(yōu)化及分頁數(shù)據(jù)性能優(yōu)化詳解
今天小編就為大家分享一篇關(guān)于MySQL Limit性能優(yōu)化及分頁數(shù)據(jù)性能優(yōu)化詳解,小編覺得內(nèi)容挺不錯的,現(xiàn)在分享給大家,具有很好的參考價值,需要的朋友一起跟隨小編來看看吧2019-03-03