Similarities and differences between truncate, delete, and drop
Note: The delete statements without the WHERE clause share the same points: truncate and delete without the WHERE clause, and drop will delete the data differences in the Table: 1. the truncate and delete statements that only delete data and do not delete the table's structure (Definition) Drop statement will delete the constraints (constrain), triggers (triggers), and indexes (indexes) that the table structure is dependent on ); stored Procedures/functions dependent on the table will be retained, but will change to the invalid state. 2. the delete statement is DML, which is put into the rollback segement and takes effect only after the transaction is committed. If a trigger exists, it is triggered during execution. truncate, drop is DDL, and the operation takes effect immediately. The original data is not placed in rollback segment and cannot be rolled back. trigger is not triggered. 3. the delete statement does not affect the extent and high watermark used by the table) keep the original location unchanged. Obviously, the drop statement will release all the space occupied by the table. The truncate statement defaults to the minextents extent, unless you use reuse storage; truncate will reset the high water line (back to the beginning ). 4. speed. Generally, drop> truncate> Delete 5. security: Use drop and truncate with caution, especially when no backup is available. otherwise, you will not be able to use it when you cry. If you want to delete some data rows, use Delete. Note that the WHERE clause is included. the rollback segment must be large enough. to delete a table, use drop to retain the table and delete all data. if it is irrelevant to the transaction, use truncate. if it is related to the transaction or you want to trigger the trigger, delete is used. if you want to organize fragments in the table, you can use truncate to keep up with the reuse Stroage, and then re-import/insert data.