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

ตัวแปร table_type ไม่ทำงานใน MySQL ใช้ default_storage_engine แทน

ตัวแปรระบบ table_type ถูก deprecated ตั้งแต่ MySQL 5.5.3 ควรใช้ default_storage_engine แทน

ตั้งค่า Storage Engine สำหรับ Session ปัจจุบัน

mysql> SET default_storage_engine = MyISAM;

สร้างตารางทดสอบ

mysql> CREATE TABLE DemoTable (
    Id INT NOT NULL AUTO_INCREMENT PRIMARY KEY
);

ตรวจสอบ Engine ของตาราง

mysql> SHOW TABLE STATUS WHERE Name = 'DemoTable';
+------------+--------+---------+------------+------+----------------+-------------+------------------+--------------+-----------+----------------+---------------------+---------------------+------------+-----------------+----------+----------------+---------+
| Name       | Engine | Version | Row_format | Rows | Avg_row_length | Data_length | Max_data_length | Index_length | Data_free | Auto_increment | Create_time         | Update_time         | Check_time | Collation       | Checksum | Create_options | Comment |
+------------+--------+---------+------------+------+----------------+-------------+------------------+--------------+-----------+----------------+---------------------+---------------------+------------+-----------------+----------+----------------+---------+
| DemoTable  | MyISAM |      10 | Fixed      |    0 |              0 |           0 | 1970324836974591 |         1024 |         0 |              1 | 2019-05-01 22:15:03 | 2019-05-01 22:15:03 | NULL       | utf8_unicode_ci | NULL     |                |         |
+------------+--------+---------+------------+------+----------------+-------------+------------------+--------------+-----------+----------------+---------------------+---------------------+------------+-----------------+----------+----------------+---------+

สังเกต: คอลัมน์ Engine แสดงเป็น MyISAM

หมายเหตุสำคัญ

  • การตั้งค่านี้มีผลต่อ Session ปัจจุบันเท่านั้น
  • MySQL 8.0.12+ ใช้ InnoDB เป็นค่าเริ่มต้น
  • เพื่อตั้งค่าตลอดกาล ให้แก้ไขในไฟล์ config (my.cnf / my.ini): default-storage-engine=MyISAM