The code to do that in InnoDB is the same that does rollback of a transaction. In other words, even a single statement may need to be undone if it is interrupted or timed out. But in InnoDB, you are always using the same code that runs transactions, even if you default to autocommit. This also makes it pretty easy for InnoDB to undelete rows if you interrupt the query or rollback the transaction.īy the way, you said you're not using transactions. When using the TRUNCATE TABLE method the. If you have an auto increment primary key column in your MyISAM table the result will be slightly different depending which delete method you use. Delete-marked rows will be removed some time later, after there are no open transactions left that might need to read that row for their view of the database. What happens when I delete all rows in MySQL In MySQL > 4.0 the number of rows deleted is returned in MySQL 3.23 the number returned is always zero. It is described here: Ī "deleted" row is really just marked with a bit in the row structure. This supports atomic updates by an internal mechanism called Multi-Versioning Concurrency Control (MVCC). The default storage engine in MySQL since 2010 is InnoDB. For this reason, it's recommended not to use MyISAM. ![]() What a mess! MyISAM does not support atomic updates. If you use MyISAM, an interrupted query leaves some of the rows deleted, and some not deleted. Or, you can also jump to our below two sections on interview questions for freshers and experienced professionals.It depends on what storage engine you use.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |