在MySQL中按引擎显示表


Answers:


129

使用INFORMATION_SCHEMA.TABLES表:

SELECT table_name FROM INFORMATION_SCHEMA.TABLES
  WHERE engine = 'InnoDB'

4
您可能还需要与架构,因此查询将如下所示:SELECT TABLE_SCHEMA,TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE引擎=“InnoDB的”
丹保龄球

81

如果要从单个数据库获得结果

SELECT TABLE_NAME FROM information_schema.TABLES
    WHERE TABLE_SCHEMA = 'dbname' AND engine = 'InnoDB';

1
我标记了这是因为您可能只想看某个模式
Csaba Toth

6

这里的其他例子。

所有引擎表(系统表除外):

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');

1

如果有人遇到问题并想查看哪个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;

问候。

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.