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

3

99

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?

Kokanee answered 23/12, 2010 at 2:46 Comment(1)
possible duplicate of How can I check MySQL engine type for a specific table?Shul
G
157

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.

Gee answered 23/12, 2010 at 4:8 Comment(2)
+1, except you always have permission to see the information schema for the objects you have permission to.New
@New 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.Gee
K
19
SELECT * FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_SCHEMA = 'db name' AND ENGINE != 'InnoDB'
Kafir answered 23/12, 2010 at 2:48 Comment(2)
Only caveat is data in INFORMATION_SCHEMA is cached, so best to use FLUSH TABLES prior to the statement you providedPerrine
It helps me to count the no of InnoDB tables in DB.Yerkovich
S
5

show create table <table> should do the trick.

Snips answered 23/12, 2010 at 2:50 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.