Show tables by engine in MySQL
Asked Answered
P

4

90

How would I show all tables in MySQL with a given engine, e.g. InnoDB, MyISAM, FEDERATED?

Pegram answered 11/11, 2009 at 21:16 Comment(0)
B
140

Use INFORMATION_SCHEMA.TABLES table:

SELECT table_name FROM INFORMATION_SCHEMA.TABLES
  WHERE engine = 'InnoDB'
Ballista answered 11/11, 2009 at 21:20 Comment(1)
You might also want the schema with that, so the query would look like: SELECT TABLE_SCHEMA, TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE engine = 'InnoDB'Lysenkoism
C
82

If you want the results from a single database

SELECT TABLE_NAME FROM information_schema.TABLES
    WHERE TABLE_SCHEMA = 'dbname' AND engine = 'InnoDB';
Cremate answered 6/9, 2012 at 5:1 Comment(1)
I marked this because you probably want to look at a certain schema onlyUncaredfor
C
7

Other examples here.

All tables by engine (except system tables):

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

All tables except engine (except system tables):

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');
Constrain answered 20/6, 2017 at 12:31 Comment(0)
J
1

If some has problem and want to see in which DB is tables with specific engine

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;

Regards.

Junia answered 26/11, 2016 at 9:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.