MySQL 5.7 使用sys.format_bytes()
100人浏览 2024-08-04 10:17:50
MySQL 5.7 使用sys.format_bytes()特性查询表库大小

-- MySQL version 5.7.31
SELECT VERSION();
-- 查询所有库所有表的大小
SELECT TABLE_SCHEMA AS 'database_name', table_name, sys.format_bytes(data_length)
FROM information_schema.`TABLES`;
-- 查询指定库所有表的大小,例如:mysql
SELECT TABLE_SCHEMA, table_name, sys.format_bytes(data_length)
FROM information_schema.`TABLES`
WHERE TABLE_SCHEMA IN ('mysql');
-- 查询指定库的大小,例如:mysql
SELECT TABLE_SCHEMA AS 'database_name', sys.format_bytes(SUM(data_length))
FROM information_schema.`TABLES`
WHERE TABLE_SCHEMA IN ('mysql');
-- 查询每个库的大小
SELECT TABLE_SCHEMA AS 'database_name', sys.format_bytes(SUM(data_length))
FROM information_schema.`TABLES`
GROUP BY TABLE_SCHEMA;
相关推荐
-
用PHP读取Excel、CSV文件2025-04-05 00:55:03
-
php替换字符你知道么,基础之数据类型--字符串2025-04-05 00:52:06
-
mysql insert 有哪4种形态?2025-04-05 00:40:40
-
php架构之CGI、FastCGI、php-fpm有什么关系?原来这么简单
php架构之CGI、FastCGI、php-fpm有什么关系?原来这么简单2025-04-05 00:37:41 -
php中抽象类和接口的对比2025-04-05 00:24:27