information_schema

select table_schema,group_concat(table_name) from tables group by table_schema;
-- 统计每个库的数据量大小,并从大到小排序 
select table_schema,sum(AVG_ROW_LENGTH*TABLE_ROWS+INDEX_LENGTH)/1024 as total_kb from information_schema.tables group by table_schema
ORDER BY total_kb DESC;
-- 配合concat()函数拼接语句或命令
-- 1.模仿以下语句,进行数据库的分库分表备份
SELECT
CONCAT("mysqldump -uroot -p123 ",table_schema," ",table_name
," >/bak/",table_schema,"_",table_name,".sql")
FROM information_schema.`TABLES`;  
SELECT
CONCAT("ALTER TABLE ",table_schema,".",table_name," DISCARD TABLESPACE;")
FROM information_schema.`TABLES`
WHERE table_schema='world';
原文地址:https://www.cnblogs.com/xuqidong/p/12635154.html