Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> MySQL

MySQL 8: ใช้ ENGINE แทน TYPE สำหรับ InnoDB

ตั้งแต่ MySQL 5.1 TYPE = InnoDB ล้าสมัย (Deprecated) ต้องใช้ ENGINE = InnoDB แทน

ตัวอย่าง Error ใน MySQL 8.0.12

mysql> CREATE TABLE Product_Information (
    -> ProductId INT,
    -> ProductName VARCHAR(10),
    -> ProductDeliveryDate DATETIME
    -> ) "TYPE = InnoDB";
ERROR 1064 (42000): syntax error near '"TYPE = InnoDB"'

ถูกต้อง: ใช้ ENGINE

mysql> CREATE TABLE Product_Information (
    -> ProductId INT,
    -> ProductName VARCHAR(10),
    -> ProductDeliveryDate DATETIME
    -> ) ENGINE = InnoDB;
Query OK, 0 rows affected

คำแนะนำ: ตรวจสอบเวอร์ชันด้วย SELECT VERSION(); MySQL 5.5+ รองรับ ENGINE แล้ว ควรใช้ ENGINE เสมอเพื่อความเข้ากันได้