如何从命令行快速验证我的数据库中的所有表都是 InnoDB?
答案1
统计每个存储引擎的表数量
SELECT COUNT(1) table_count,engine
FROM information_schema.tables
WHERE table_schema NOT IN ('information_schema','mysql')
GROUP BY engine;
或者检查每个数据库的存储引擎数量
SELECT COUNT(1) table_count,table_schema,engine
FROM information_schema.tables
WHERE table_schema NOT IN ('information_schema','mysql')
GROUP BY table_schema,engine;
或者获取所有非 InnoDB 表的数量(应为 0)
SELECT COUNT(1) table_count
FROM information_schema.tables
WHERE table_schema NOT IN ('information_schema','mysql')
AND engine <> 'InnoDB';
列出非 InnoDB 表的名称以及该表存储在哪个数据库中
SELECT table_schema,table_name
FROM information_schema.tables
WHERE table_schema NOT IN ('information_schema','mysql')
AND engine <> 'InnoDB';
答案2
mysql> USE xyz;
mysql> SHOW TABLE STATUS;
它为您提供了所有表及其引擎的列表。