-- 查询 MySQL 数据库大小的 SQL 语句
-- 方法1:使用 information_schema 表
SELECT
table_schema AS '数据库名',
SUM(data_length + index_length) / 1024 / 1024 AS '数据库大小(MB)'
FROM
information_schema.tables
GROUP BY
table_schema;
-- 方法2:使用 SHOW TABLE STATUS 命令
SELECT
table_schema AS '数据库名',
SUM(data_length + index_length) / 1024 / 1024 AS '数据库大小(MB)'
FROM
(SHOW TABLE STATUS) AS tables
GROUP BY
table_schema;
方法1:
information_schema.tables
表来查询每个数据库的大小。data_length
和 index_length
分别表示数据和索引占用的空间大小。方法2:
SHOW TABLE STATUS
命令来获取表的状态信息,包括数据和索引的大小。这两种方法都可以有效地查询 MySQL 数据库的大小。
上一篇:mysql日期格式
下一篇:mysql 命令行登录
Laravel PHP 深圳智简公司。版权所有©2023-2043 LaravelPHP 粤ICP备2021048745号-3
Laravel 中文站