Computer >> Hướng Dẫn Máy Tính >  >> Lập Trình >> MySQL

MySQL - Thay đổi engine bảng từ InnoDB sang MyISAM


Trước tiên, tạo một bảng mẫu:

mysql> create table DemoTable1982 ( StudentId int, StudentName varchar(20), StudentAge int ); Query OK, 0 rows affected (0.00 sec)

Kiểm tra engine của bảng:

mysql> show create table DemoTable1982;

Kết quả hiển thị engine mặc định là InnoDB:

+---------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table         | Create Table                                                                                                                                                                                                                           |
+---------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| DemoTable1982 | CREATE TABLE `demotable1982` (`StudentId` int(11) DEFAULT NULL, `StudentName` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL, `StudentAge` int(11) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci |
+---------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

Truy vấn thay đổi engine sang MyISAM:

mysql> alter table DemoTable1982 ENGINE='MyISAM'; Query OK, 0 rows affected (0.00 sec) Records: 0 Duplicates: 0 Warnings: 0

Kiểm tra lại engine sau khi thay đổi:

mysql> show create table DemoTable1982;

Kết quả xác nhận engine đã chuyển sang MyISAM:

+---------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table         | Create Table                                                                                                                                                                                                                           |
+---------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| DemoTable1982 | CREATE TABLE `demotable1982` ( `StudentId` int(11) DEFAULT NULL, `StudentName` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL, `StudentAge` int(11) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci |
+---------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)