Deletes the name of a table (record and structure) Delete ———— truncate ———— drop
Delete (delete the statement that is logged in the datasheet)
DELETE from table name WHERE condition;
Note: Deleting records does not release the data block tablespace that is occupied in Oracle. It only marks those deleted chunks of data as unused.
If you are sure you want to delete all records in a large table, you can use the TRUNCATE command, which frees up the data block tablespaces that occupy
TRUNCATE table name;
This operation cannot be rolled back.
Same point
Truncate and delete with no WHERE clause, and drop deletes data in the table
Note that the delete here is the DELETE statement without the WHERE clause
Different points:
1. Truncate and delete Delete only the data do not delete the structure of the table (definition)
The DROP statement deletes the table's structure-dependent constraints (constrain), triggers (trigger), indexes (index); Stored procedures/functions that depend on the table are preserved, but become invalid states.
The 2.delete statement is DML, which is placed in the rollback segement, which takes effect after the transaction is committed, and if the corresponding trigger is present, the execution is triggered.
Truncate,drop is DDL, the operation takes effect immediately, the original data is not placed in the rollback segment and cannot be rolled back. Operation does not trigger trigger.
The 3.delete statement does not affect the extent that the table occupies, and the high watermark (watermark) keeps the original position.
Obviously the drop statement frees up all the space that the table occupies
Truncate statement by default see space released to minextents extent unless the reuse storage is used; Truncate will reset the high waterline (back to the beginning).
4. Speed, in general: drop>; Truncate >; Delete
5. Security: Be careful with drop and truncate, especially when there is no backup. Otherwise, it's too late to cry.
Use, to delete some data rows with delete, note the WHERE clause is taken. The rollback segment should be large enough.
Want to delete the table, of course with drop
You want to keep the table and delete all the data. If it has nothing to do with the transaction, use truncate. If it is related to a transaction, or if you want to trigger trigger, or delete.
If you are defragmenting the inside of the table, you can use truncate to keep up with reuse stroage and then re-import/Insert Data
Delete a column of statements from a table in Oracle
ALTER TABLE name drop colum column name