我如何知道 mysql 表是使用 myISAM 还是 InnoDB Engine?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4515490/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I know if a mysql table is using myISAM or InnoDB Engine?
提问by kamal
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:
在 MySQL 中,没有办法为某个数据库指定存储引擎,只能为单个表指定存储引擎。但是,您可以指定在一个会话期间使用的存储引擎:
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?
如果确实所有表都使用 InnoDB,我如何确认?
回答by TehShrike
If you use SHOW CREATE TABLE, you have to parse the engine out of the query.
如果使用 SHOW CREATE TABLE,则必须从查询中解析引擎。
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).
从 INFORMATION_SCHEMA 数据库中选择是不好的做法,因为开发人员保留随时更改其架构的权利(尽管不太可能)。
The correct query to use is SHOW TABLE STATUS- you can get information on all the tables in a database:
要使用的正确查询是SHOW TABLE STATUS- 您可以获得有关数据库中所有表的信息:
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.
您将返回的列之一是引擎。
回答by The Scrum Meister
SELECT * FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_SCHEMA = 'db name' AND ENGINE != 'InnoDB'
回答by Matt Caldwell
show create table <table>
should do the trick.
show create table <table>
应该做的伎俩。