简体   繁体   English

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

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

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

To determine the storage engine being used by a table, you can use show table status . 要确定表正在使用的存储引擎,可以使用show table status The Engine field in the results will show the database engine for the table. 结果中的“ Engine字段将显示该表的数据库引擎。 Alternately, you can select the engine field from information_schema.tables : 或者,您可以从information_schema.tables选择engine字段:

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

alter table the_table engine = InnoDB;

Where, of course, you can specify any available storage engine. 当然,您可以在哪里指定任何可用的存储引擎。

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

SHOW TABLE STATUS FROM `database`;

will list everything for all tables, starting with whether they are MyISAM or InnoDB. 将列出所有表的所有内容,从它们是MyISAM还是InnoDB开始。 if you desire to list only data regarding 1 table, the syntax below may be used* : 如果您只希望列出有关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. *请注意,在LIKE之后,将GRAVE ACCENT(`反引号)用作数据库名称和表名称,并将SINGLE QUOTE(')用作比较字符串(表名称的一部分)。

` != ' '!='

Here is a query that lists all tables in all databases 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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM