How do I know if a mysql table is using myISAM or InnoDB Engine?

69,110

Solution 1

If you use SHOW CREATE TABLE, you have to parse the engine out of the query.

Selecting from the INFORMATION_SCHEMA database is poor practice, as the devs reserve the right to change its schema at any time (though it is unlikely).

The correct query to use is SHOW TABLE STATUS - you can get information on all the tables in a database:

SHOW TABLE STATUS FROM `database`;

Or for a specific table:

SHOW TABLE STATUS FROM `database` LIKE 'tablename';

One of the columns you will get back is Engine.

Solution 2

SELECT * FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_SCHEMA = 'db name' AND ENGINE != 'InnoDB'

Solution 3

show create table <table> should do the trick.

Share:
69,110
kamal
Author by

kamal

Updated on July 08, 2022

Comments

  • kamal
    kamal almost 2 years

    In MySQL, there is no way to specify a storage engine for a certain database, only for single tables. However, you can specify a storage engine to be used during one session with:

    SET storage_engine=InnoDB;
    

    So you don't have to specify it for each table.

    How do I confirm, if indeed all the tables are using InnoDB?

  • OMG Ponies
    OMG Ponies over 13 years
    Only caveat is data in INFORMATION_SCHEMA is cached, so best to use FLUSH TABLES prior to the statement you provided
  • Konerak
    Konerak over 13 years
    +1, except you always have permission to see the information schema for the objects you have permission to.
  • TehShrike
    TehShrike over 13 years
    @Konerak Ah, true enough - I'll correct the answer. As an aside, I have seen some bugs where selecting from information_schema did not work in cases where people had the correct permissions.
  • Anon30
    Anon30 almost 9 years
    It helps me to count the no of InnoDB tables in DB.