Will MySQL lock the table after emptying the table data?

PHP developers, will the MySQL datasheet lock up when it empties the data? I don"t know much about the database.

Jan.15,2022

see how you use it. The drop time is longer, and the truncate time is much faster, but there is also a short lock, which is recommended when the business is idle.


delete from table
MyISAM : table write lock
InnoDB : row write lock (exclusive lock). A single delete affects only one piece of data, and a whole table deletion will have next-key lock, which is similar to a table lock

.

truncate
truncate is essentially a DDL operation, which is locked at the table level, but faster than delete . The disadvantage is that it cannot be rolled back and the trigger will not be triggered

.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3ed19-4dae0.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3ed19-4dae0.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?