mysql查看數(shù)據(jù)庫空間容量剩余

小億
377
2023-12-28 07:52:14
欄目: 云計(jì)算

您可以使用以下查詢來查看MySQL數(shù)據(jù)庫的空間容量剩余:

SELECT table_schema AS '數(shù)據(jù)庫名',
       ROUND(SUM(data_length + index_length) / 1024 / 1024, 2) AS '總大小(MB)',
       ROUND(SUM(data_length) / 1024 / 1024, 2) AS '數(shù)據(jù)大小(MB)',
       ROUND(SUM(index_length) / 1024 / 1024, 2) AS '索引大小(MB)',
       ROUND(SUM(data_free) / 1024 / 1024, 2) AS '可用空間(MB)'
FROM information_schema.tables
GROUP BY table_schema;

這個(gè)查詢將返回每個(gè)數(shù)據(jù)庫的總大小、數(shù)據(jù)大小、索引大小和可用空間大?。ㄒ訫B為單位)。您可以根據(jù)需要修改查詢以適應(yīng)您的環(huán)境。

0