Difference between truncate, delete, drop

truncate

  • DDL does not delete table structure, only table data;
  • Delete all rows at once, do not count in the log, cannot be rolled back,
  • When deleting data, it is equivalent to delete from table. (see the difference below)
  • When truncate deletes a table, the space occupied by indexes and foreign keys will return to the minimum initialized; triggers cannot be triggered

delete

  • DML does not delete the table structure, only deletes the data;
  • Delete line by line, each deleted line is counted in the log and can be rolled back;
  • Indexes and foreign keys are maintained

drop

  • DDL deletes the entire table structure, the fastest

 

 

  1. 速度:drop>truncate>delete
  2. delete from table and truncate: For tables referenced by foreign key constraints, you cannot use truncate, use delete
  3. Only delete can be rolled back

 

http://www.cnblogs.com/zhizhao/p/7825469.html

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324834089&siteId=291194637