如何确定 mysql 数据库的类型:它是 InnoDB 还是 MyISAM?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1638070/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 14:22:48  来源:igfitidea点击:

How can I determine type of mysql database : whether it is InnoDB or MyISAM?

sqlmysqltypes

提问by Rachel

  • How can I determine type of mysql database : whether it is InnoDB or MyISAM ?
  • How can I convert MyISAM to InnoDB or vice-versa ?
  • 如何确定 mysql 数据库的类型:它是 InnoDB 还是 MyISAM?
  • 如何将 MyISAM 转换为 InnoDB,反之亦然?

回答by James McNellis

To determine the storage engine being used by a table, you can use show table status. The Enginefield in the results will show the database engine for the table. Alternately, you can select the enginefield from information_schema.tables:

要确定表使用的存储引擎,您可以使用show table status. Engine结果中的字段将显示表的数据库引擎。或者,您可以从以下engine字段中选择字段information_schema.tables

select engine 
from   information_schema.tables 
where  table_schema = 'schema_name'
   and table_name = 'table_name' 

You can change between storage engines using alter table:

您可以使用alter table以下方法在存储引擎之间进行更改:

alter table the_table engine = InnoDB;

Where, of course, you can specify any available storage engine.

当然,您可以在其中指定任何可用的存储引擎。

回答by mr-euro

Select the database in question and run show table status;

选择有问题的数据库并运行 show table status;

回答by tony gil

SHOW TABLE STATUS FROM `database`;

will list everything for all tables, starting with whether they are MyISAM or InnoDB. if you desire to list only data regarding 1 table, the syntax below may be used* :

将列出所有表的所有内容,从它们是 MyISAM 还是 InnoDB 开始。如果您只想列出有关 1 个表的数据,可以使用以下语法*:

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

to change the table engine:

更改表引擎:

ALTER TABLE `table` ENGINE=InnoDB;

*attention use the GRAVE ACCENT (` backtick) for the database name and the table name and the SINGLE QUOTE (') for the comparison string (portion of table name) after LIKE.

*注意使用 GRAVE ACCENT(` 反引号)作为数据库名和表名,在 LIKE 之后使用单引号(')作为比较字符串(表名的一部分)。

` != '

` != '

回答by CODE-REaD

Here is a query that lists alltables in alldatabases and their storage engines:

这是一个列出所有数据库中的所有表及其存储引擎的查询:

SELECT table_name, table_schema, engine
FROM information_schema.tables;

(From https://serverfault.com/a/244792/406647)

(来自https://serverfault.com/a/244792/406647