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

Đổi engine bảng trong MySQL

Dùng ALTER TABLE ... ENGINE = ....

Cú pháp:

alter table yourTableName ENGINE = yourEngineName;

Tạo bảng engine MyISAM:

mysql> create table ChangeEngineTableDemo
-> (
-> MovieId int,
-> MovieName varchar(100),
-> IsPopular bool
-> )ENGINE = 'MyISAM';
Query OK, 0 rows affected (0.37 sec)

Đổi sang InnoDB:

mysql> alter table ChangeEngineTableDemo ENGINE = InnoDB;
Query OK, 0 rows affected (2.21 sec)
Records: 0 Duplicates: 0 Warnings: 0

Kiểm tra:

mysql> show create table ChangeEngineTableDemo;

Kết quả cho thấy ENGINE = InnoDB.