[Interview Question] The difference between MySQL's commonly used storage engines MYISAM and InnoDB

MySQL commonly used storage engine




Transaction support

MyISAM does not support transactions, while InnoDB supports it, and is automatically committed by default. Transaction operations in spring are actually operating database transactions;



File storage structure

MYISAM:
Insert picture description here

  • role.frm: table structure file
  • role.MYD: Data file (MyISAM Data)
  • role.MYI: Index file (MyISAM Index)

InnoDB:

Insert picture description here

  • user.frm: table structure file
  • user.ibd: index and data file (InnoDB Data)


Underlying structure

The bottom layer is stored by B+Tree

  • MYISAM: The leaf node stores the address of the data

Insert picture description here



  • InnoDB: Leaf nodes store data, so InnoDB's index is also called a clustered index
    Insert picture description here


lock

  • MYISAM supports table locks, but does not support row locks.
  • InnoDB supports table locks and row locks.


Table master and foreign key

  • MYISAM allows the existence of tables without any indexes and primary keys. The indexes are the addresses where rows are stored.

  • If InnoDB does not set a primary key or a non-empty unique index, it will automatically generate a 6-byte primary key (not visible to the user)

  • MYISAM does not support foreign keys

  • InnoDB supports foreign keys

Guess you like

Origin blog.csdn.net/qq_42380734/article/details/108714312