如何使用给定引擎(例如InnoDB,MyISAM,FEDERATED)显示MySQL中的所有表?
Answers:
SELECT table_name FROM INFORMATION_SCHEMA.TABLES
WHERE engine = 'InnoDB'
如果要从单个数据库获得结果
SELECT TABLE_NAME FROM information_schema.TABLES
WHERE TABLE_SCHEMA = 'dbname' AND engine = 'InnoDB';
这里的其他例子。
所有引擎表(系统表除外):
SELECT TABLE_SCHEMA as DbName ,TABLE_NAME as TableName ,ENGINE as Engine
FROM information_schema.TABLES
WHERE ENGINE = 'MyISAM' -- or InnoDB or whatever
AND TABLE_SCHEMA NOT IN('mysql','information_schema','performance_schema');
除引擎外的所有表(系统表除外):
SELECT TABLE_SCHEMA as DbName ,TABLE_NAME as TableName ,ENGINE as Engine
FROM information_schema.TABLES
WHERE ENGINE != 'MyISAM' -- or InnoDB or whatever
AND TABLE_SCHEMA NOT IN('mysql','information_schema','performance_schema');
如果有人遇到问题并想查看哪个DB是具有特定引擎的表
SELECT
(SELECT group_concat(TABLE_NAME)
FROM information_schema.TABLES
WHERE TABLE_SCHEMA = 'database1'
AND engine = 'MyIsam'
) as database1,
(SELECT group_concat(TABLE_NAME)
FROM information_schema.TABLES
WHERE TABLE_SCHEMA = 'database2'
AND engine = 'MyIsam'
) as database2,
(SELECT group_concat(TABLE_NAME)
FROM information_schema.TABLES
WHERE TABLE_SCHEMA = 'database3'
AND engine = 'MyIsam'
) as database3;
问候。