Delete statements in the database comparison of the same points and different points of drop, delete, truncate (example) Database Delete statements: Delete: Used to delete rows in a table (note: You can delete a row You can also delete all rows without deleting the table (meaning the structure, properties, index of the table) Syntax: delete a row: Delete from table name &nb Sp Where Column name = value Delete all rows: Delete from table name or De lete * from table name drop: Used to delete a table (note: The structure, properties, and indexes of the table are also deleted.) Syntax: drop table table name truncate: Used to delete data within a table (note: Delete only the data in the table, not the table itself, Equivalent to the DELETE statement does not write the WHERE clause) syntax: Truncate table Table name Comparison of the same point and different points of the deleted statement in the database: The same point: 1. Truncate and delete without a WHERE clause, and drop can delete data within a table 2.truncate and delete only remove Table data preserve table structure different points: www.2cto.com 1. truncate TABLE tablename Delete table content frees the tablespace to preserve the table structure (that is, delete only the data within the table and not delete the table itself.) The equivalent of the DELETE statement does not write the WHERE clause), without the use of transaction-and-transaction-independent TRUNCATE statements by default freeing space to minextents extent, unless using reuse Storage;truncate will reset the high watermark (back to the beginning). 2. Delete Table TableName [WHERE clause] delete belongs to data manipulation language (DML), the transaction cannot be committed automatically, commit This operation will be put into rollback segement, after the transaction is committed; if there is a corresponding trigger, execution will be triggered. The DELETE statement does not affect the extent occupied by the table, and the high waterline (HI Watermark) retains its original position 3. drop table tablename drop belongs to the data definition language (DDL) that can automatically commit a transaction; the drop statement deletes the structure of the table that is dependent on the constraint (constrain), the trigger (trigger), the index ( Index) "Delete table data at the same time delete table structure"; the stored procedure/function that depends on the table will remain, but becomes invalid state. The DROP statement frees all the space occupied by the table. Delete data speed, generally: drop> truncate > delete Use occasion: when you no longer need the table, use drop; when you still want to keep the table, but to delete all records, use the truncate; when you want to delete a partial record (always with a WHERE clause), use Delete. Note: for tables that have a primary foreign key relationship, You cannot use truncate and you should use a DELETE statement without a WHERE clause, because truncate is not recorded in the log, the trigger cannot be activated
Delete statement drop, delete, truncate and different points in the
data