mysql查询某个库下所有表的数据量
    		       		warning:
    		            这篇文章距离上次修改已过426天,其中的内容可能已经有所变动。
    		        
        		                
                要查询MySQL数据库下所有表的数据量,可以使用以下SQL语句:
SELECT table_name, table_rows 
FROM information_schema.tables 
WHERE table_schema = 'your_database_name' 
ORDER BY table_rows DESC;将your_database_name替换为你要查询的数据库名称。这个查询会返回每个表的名称及其行数,按行数降序排列。
如果你想查询包括存储过程和函数在内的所有数据库对象的行数,可以使用以下查询:
SELECT table_schema AS `Database`, 
SUM(table_rows) AS `TotalRows` 
FROM information_schema.tables 
WHERE table_schema = 'your_database_name' 
UNION 
SELECT `routine_schema` AS `Database`, 
SUM(`definition` = 'FUNCTION') AS `TotalRows` 
FROM information_schema.routines 
WHERE `routine_schema` = 'your_database_name' 
GROUP BY `Database`;这个查询将会返回指定数据库以及存储过程和函数的总行数。请确保替换your_database_name为你的数据库名称。
评论已关闭