MySQL查看資料庫表容量大小

jacklove
發布: 2019-02-23 15:34:37
原創
22273 人瀏覽過

本文介紹MySQL查看資料庫表格容量大小的指令語句,提供完整查詢語句及實例,方便大家學習使用。

相關mysql影片教學推薦:《mysql教學

#1.查看所有資料庫容量大小

select table_schema as '数据库',sum(table_rows) as '记录数',sum(truncate(data_length/1024/1024, 2)) as '数据容量(MB)',sum(truncate(index_length/1024/1024, 2)) as '索引容量(MB)'from information_schema.tablesgroup by table_schemaorder by sum(data_length) desc, sum(index_length) desc;
登入後複製

2.查看所有資料庫各表容量大小

select table_schema as '数据库',
table_name as '表名',
table_rows as '记录数',truncate(data_length/1024/1024, 2) as '数据容量(MB)',truncate(index_length/1024/1024, 2) as '索引容量(MB)'from information_schema.tablesorder by data_length desc, index_length desc;
登入後複製

3.查看指定資料庫容量大小

例如範例:查看mysql庫容量大小

select table_schema as '数据库',sum(table_rows) as '记录数',sum(truncate(data_length/1024/1024, 2)) as '数据容量(MB)',sum(truncate(index_length/1024/1024, 2)) as '索引容量(MB)'from information_schema.tableswhere table_schema='mysql';
登入後複製

MySQL查看資料庫表容量大小
4.查看指定資料庫各表容量大小

例:查看mysql庫各表容量大小

select table_schema as '数据库',
table_name as '表名',
table_rows as '记录数',truncate(data_length/1024/1024, 2) as '数据容量(MB)',truncate(index_length/1024/1024, 2) as '索引容量(MB)'from information_schema.tableswhere table_schema='mysql'order by data_length desc, index_length desc;
登入後複製

MySQL查看資料庫表容量大小

本文講解了MySQL查看資料庫表容量大小,更多相關知識請關注php中文網。

相關推薦:

詳解PHP封裝的一個單例模式Mysql操作類別

解讀php的PDO連線資料庫的相關內容

如何透過php用程式碼實作遞迴取得一個陣列中指定key的值

##

以上是MySQL查看資料庫表容量大小的詳細內容。更多資訊請關注PHP中文網其他相關文章!

相關標籤:
來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!