本文介紹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';
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查看資料庫表容量大小,更多相關知識請關注php中文網。
相關推薦:
##
以上是MySQL查看資料庫表容量大小的詳細內容。更多資訊請關注PHP中文網其他相關文章!