如何更改MySQL数据库表的数据库引擎?
首先,确定MySQL数据库的类型,即其引擎是InnoDB还是MyISAM。为此,请使用information_schema.columns.tables中的engine列。
语法如下。
SELECT ENGINE FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = ’yourDatabaseName’ AND TABLE_NAME = ’yourTableName’;
在这里,我有一个名为“StudentInformations”的表-
mysql> create table StudentInformations -> ( -> StudentId int not null auto_increment, -> StudentFirstName varchar(20), -> StudentLastName varchar(20), -> Primary Key(StudentId) -> );
现在,您可以使用上述语法的实现知道该表正在使用InnoDB还是MyISAM。我们的数据库是“测试”。
对于相同的查询如下-
mysql> select engine from information_schema.tables -> where table_schema = 'test' -> and table_name = 'StudentInformations';
以下是输出-
+--------+ | ENGINE | +--------+ | InnoDB | +--------+ 1 row in set (0.05 sec)
使用alter命令更改“StudentInformations”表的引擎。更改任何表的引擎的语法如下。
ALTER TABLE yourTableName ENGINE = ‘yourEngineName’;
现在让我们将引擎InnoDB更改为MyISAM。查询如下-
mysql> alter table StudentInformations ENGINE = 'MyISAM'; Records − 6 Duplicates − 0 Warnings − 0
上面显示的结果显示,由于表中有6行,因此6行受到影响。
要检查表是否从InnoDB转换为MyISAM,以下是查询-
mysql> select engine from information_schema.tables -> where table_schema = 'test' -> and table_name = 'StudentInformations';
这是显示引擎已成功更新的输出-
+--------+ | ENGINE | +--------+ | MyISAM | +--------+ 1 row in set (0.00 sec)
热门推荐
1 训练狗狗憋尿
2 狗狗追踪训练
3 狗狗训练要多少钱
5 深圳狗狗训练
6 训练狗狗唤回
7 狗狗叫怎么训练
8 狗狗训练班
10 狗狗社会化训练
11 狗狗叫回训练
12 广州狗狗训练学校
13 狗狗训练躺下
14 狗狗随行训练
15 训练狗狗巡回
16 狗狗要怎么训练
17 狗狗喂食训练
18 训练狗狗躺下