Difference between delete and truncate: deletetruncate
Similarities: The truncate function is the same as the delete statement without the WHERE clause: both delete all rows in the table. Use truncate with caution. After deletion, it will disappear.
1. delete: deleting a "Table Record" will record the operation in the log, and the deleted data can be restored through transaction rollback.
Truncate: deleting "table records" cannot be recovered.
2. delete: delete a row each time and record one row in the transaction log.
Truncate: deletes data from the data page used to release table data, and only records the release of pages in transaction logs.
Therefore, truncate is faster than delete.
3. delete: delete the content. Release the space without deleting the definition.
Truncate: Delete the content. Do not delete the definition or release the space.
4. delete: the statement does not affect the extent used by the table. The high w2atermark (high waterline) keeps the original position unchanged.
Truncate: by default, the statement releases the space to the extent of minextents, unless reuse storage is used; truncate resets the high water line (back to the beginning ).
To delete some data rows, use delete. Note that the where clause should be included. The rollback segment should be large enough.
To delete a table, use drop
Delete all data if you want to keep the table. If it is not related to the transaction, use truncate. If it is related to the transaction or you want to trigger the trigger, use delete.