在 MySQL 中更改表引擎

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

Changing Table Engine in MySQL

mysqldatabaseinnodbmyisam

提问by AliBZ

I am using mysql and mysql workbench. I created 5 tables with innodb engine. I checked their engine and it was innodb before I insert data into them. I inserted data from 5 MyISAM tables and now my innodb tables are MyISAM. I can't change them. I used the alter table engine=innodb but it doesn't work.

我正在使用 mysql 和 mysql 工作台。我用 innodb 引擎创建了 5 个表。我检查了他们的引擎,在我插入数据之前它是 innodb。我从 5 个 MyISAM 表插入数据,现在我的 innodb 表是 MyISAM。我无法改变它们。我使用了 alter table engine=innodb 但它不起作用。

回答by Matt Healy

From the manual: http://dev.mysql.com/doc/refman/5.1/en/alter-table.html

从手册:http: //dev.mysql.com/doc/refman/5.1/en/alter-table.html

For example, to convert a table to be an InnoDBtable, use this statement:

例如,要将表转换为InnoDB表,请使用以下语句:

ALTER TABLE t1 ENGINE = InnoDB;

The outcome of attempting to change a table's storage engine is affected by whether the desired storage engine is available and the setting of the NO_ENGINE_SUBSTITUTIONSQL mode, as described in Section 5.1.11, “Server SQL Modes”.

尝试更改表的存储引擎的结果受所需存储引擎是否可用以及NO_ENGINE_SUBSTITUTIONSQL 模式设置的影响,如第 5.1.11 节“服务器 SQL 模式”中所述。

https://dev.mysql.com/doc/refman/8.0/en/sql-mode.html#sqlmode_no_engine_substitution

https://dev.mysql.com/doc/refman/8.0/en/sql-mode.html#sqlmode_no_engine_substitution

When you create the table do you get any warning about the Engine type being unavailable?

创建表时,您是否收到有关引擎类型不可用的任何警告?

回答by ClearCrescendo

It's not obvious. If you edit the table and then select the column tabthe engine widget is not immediately visible. On the upper right of the edit window you will see two down pointing chevrons. Select the arrow onceand additional widgets will appear. In the upper right hand corner there will now be widgetsfor the schema and engine.

这并不明显。如果您编辑表格然后选择列选项卡,引擎小部件不会立即可见。在编辑窗口的右上角,您将看到两个向下指向的 V 形。选择一次箭头,将出现其他小部件。在右上角,现在将有模式和引擎的小部件

Result

结果