mysql in truncate, delete and drop

1. truncate and delete only delete data without deleting the table structure (defined)  

  drop table delete statement structure is dependent constraints (constrain), the trigger (Trigger), an index (index); dependent table stored in the procedure / function will be retained, but becomes invalid state.  

2.delete statement is dml, this action will put rollback segement, the only take effect after the transaction commits; if there is a corresponding trigger, when the execution will be triggered.  

  truncate, drop is ddl, operating with immediate effect, the original data is not put rollback segment can not be rolled back. operation does not trigger the trigger.  

3.delete statements do not affect the table occupied by the extent, high waterline (high watermark) to maintain the original position does not move  
  drop statements will release all the space occupied by the table  

  Under truncate statement released into space by default minextents a extent, unless reuse storage; truncate will reset the high water line (back to the beginning).  

4. Speed, general: drop> truncate> delete  

5. Security: Be careful using the drop and truncate, in particular when no backup

  Delete some rows with delete, to bring attention to the where clause. Rollback segments should be large enough. 

Reproduced in: https: //www.cnblogs.com/caly/archive/2012/02/06/2340419.html

Guess you like

Origin blog.csdn.net/weixin_33682719/article/details/93538092