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

แสดง Storage Engine ของตารางใน MySQL ด้วย SHOW TABLE STATUS

ตรวจสอบว่า Table ใช้ Engine อะไร (InnoDB/MyISAM/อื่นๆ)

1. ดู Engine ของทุกตารางใน Database

SHOW TABLE STATUS FROM your_database_name;

2. ดู Engine ของตารางเฉพาะ

SHOW TABLE STATUS FROM your_database_name LIKE 'your_table_name';

ตัวอย่างผลลัพธ์

คำสั่ง: SHOW TABLE STATUS FROM sampleTest;

NameEngineVersionRow_formatRowsData_lengthAuto_incrementCreate_timeCollation
datetimedemoInnoDB10Dynamic016384NULL2018-12-05 09:22:54utf8mb4_0900_ai_ci
primarydemoInnoDB10Dynamic016384NULL2018-12-05 09:23:34utf8mb4_0900_ai_ci
studentMyISAM10Dynamic0012018-12-05 09:22:22utf8mb4_0900_ai_ci

คิวรี่ตารางเดียว: SHOW TABLE STATUS FROM sampletest LIKE 'student';

NameEngineRow_formatRowsData_length
studentMyISAMDynamic00

คอลัมน์สำคัญในผลลัพธ์

  • Engine - Storage Engine (InnoDB, MyISAM, Memory, CSV, ฯลฯ)
  • Row_format - รูปแบบการจัดเก็บแถว (Dynamic, Compact, Compressed, Redundant)
  • Rows - จำนวนแถวประมาณ (InnoDB เป็นประมาณการ)
  • Data_length - ขนาดข้อมูล (Bytes)
  • Index_length - ขนาดดัชนี (Bytes)
  • Auto_increment - ค่า AUTO_INCREMENT ถัดไป
  • Create_time / Update_time - เวลาสร้าง/แก้ไขล่าสุด
  • Collation - Collation เริ่มต้นของตาราง

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

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

วิธีนี้ง่ายกว่าสำหรับ Query ในโปรแกรม