如何知道mysql表是使用myISAM还是InnoDB引擎?

时间:2022-09-21 07:25:12

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?

3 个解决方案

#1


111  

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

如果使用SHOW CREATE表,则必须从查询中解析引擎。

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.

你会得到的其中一列是引擎。

#2


11  

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

#3


2  

show create table <table> should do the trick.

显示创建表 <表> 应该可以做到这一点。

#1


111  

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

如果使用SHOW CREATE表,则必须从查询中解析引擎。

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.

你会得到的其中一列是引擎。

#2


11  

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

#3


2  

show create table <table> should do the trick.

显示创建表 <表> 应该可以做到这一点。