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

วิธีเช็คว่า MySQL Table ใช้ Engine MyISAM หรือ InnoDB

คำสั่งสำหรับตารางเฉพาะ

SHOW TABLE STATUS FROM yourDatabaseName LIKE 'yourTableName';

ตัวอย่าง

mysql> show table status from business like 'student';
+---------+--------+---------+------------+------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+-------------+------------+--------------------+----------+----------------+---------+
| 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 |
+---------+--------+---------+------------+------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+-------------+------------+--------------------+----------+----------------+---------+
| student | InnoDB | 10      | Dynamic    | 2    | 8192           | 16384       | 0               | 32768        | 0         | NULL           | 2018-10-01 12:26:57 | NULL        | NULL       | utf8mb4_unicode_ci | NULL     |                |         |
+---------+--------+---------+------------+------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+-------------+------------+--------------------+----------+----------------+---------+

คอลัมน์ Engine = InnoDB

คำสั่งสำหรับทุกตารางใน Database

SHOW TABLE STATUS FROM yourDatabaseName;

ผลลัพธ์ (ดูคอลัมน์ Engine)

จะแสดงรายการตารางทั้งหมดพร้อม Engine Type แต่ละตัว

วิธีอื่น: ใช้ INFORMATION_SCHEMA

SELECT TABLE_NAME, ENGINE 
FROM INFORMATION_SCHEMA.TABLES 
WHERE TABLE_SCHEMA = 'yourDatabaseName';

วิธีนี้ให้ผลลัพธ์กระชับ เหมาะสำหรับ Query ในโปรแกรม