【MySQL】修改表的存储引擎

查看表的存储引擎用命令 show create table 表名

更改表的存储引擎用命令 alter table 表名 set ENGINE=新引擎名

示例如下:

mysql> show create table t01;
+-------+------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table                                                                                                                             |
+-------+------------------------------------------------------------------------------------------------------------------------------------------+
| t01   | CREATE TABLE `t01` (
  `id` int(11) NOT NULL,
  `name` varchar(22) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 |
+-------+------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.05 sec)

mysql> alter table t01 engine=MyISAM;
Query OK, 0 rows affected (0.23 sec)
Records: 0  Duplicates: 0  Warnings: 0

mysql> show create table t01;
+-------+------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table                                                                                                                             |
+-------+------------------------------------------------------------------------------------------------------------------------------------------+
| t01   | CREATE TABLE `t01` (
  `id` int(11) NOT NULL,
  `name` varchar(22) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 |
+-------+------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

mysql>

玩完后记得改回原样哦。

mysql> alter table t01 ENGINE=INNODB;
Query OK, 0 rows affected (0.14 sec)
Records: 0  Duplicates: 0  Warnings: 0

mysql> show create table t01;
+-------+------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table                                                                                                                             |
+-------+------------------------------------------------------------------------------------------------------------------------------------------+
| t01   | CREATE TABLE `t01` (
  `id` int(11) NOT NULL,
  `name` varchar(22) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 |
+-------+------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

--END--

原文地址:https://www.cnblogs.com/heyang78/p/15120365.html