สำหรับการแปลง engine ให้ใช้คำสั่ง ALTER ครับ
สร้างตารางตัวอย่าง (engine เริ่มต้นเป็น MyISAM)
mysql> create table DemoTable (
-> ClientId int NOT NULL AUTO_INCREMENT,
-> ClientName varchar(100),
-> ClientAge int,
-> ClientCountryName varchar(100),
-> isMarried boolean,
-> PRIMARY KEY(ClientId)
-> ) ENGINE=MyISAM;
Query OK, 0 rows affected (0.67 sec)
คำสั่งแปลงจาก MyISAM เป็น InnoDB
mysql> alter table DemoTable ENGINE=InnoDB; Query OK, 0 rows affected (1.97 sec) Records: 0 Duplicates: 0 Warnings: 0
ตรวจสอบสถานะตาราง
mysql> show create table DemoTable;
ผลลัพธ์ (แสดง ENGINE อัปเดตเป็น InnoDB)
CREATE TABLE `DemoTable` ( `ClientId` int(11) NOT NULL AUTO_INCREMENT, `ClientName` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, `ClientAge` int(11) DEFAULT NULL, `ClientCountryName` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, `isMarried` tinyint(1) DEFAULT NULL, PRIMARY KEY (`ClientId`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci
คำอธิบาย: InnoDB รองรับ transaction, foreign key, row-level locking เหมาะสำหรับระบบที่ต้องการความน่าเชื่อถือสูง MyISAM เหมาะสำหรับ read-heavy workload