Skip to main content

Posts

Showing posts from March, 2017

SQL Server difference between DELETE, TRUNCATE, DROP

DELETE DELETE removes some specific rows (with WHERE clause) or all rows (without WHERE clause) The operation can be rolled back.    DELETE is a DML command. This operation cause all DELETE triggers on table to fire. Conditions like WHERE clause can be used. Note: when we issue a DELETE command then all data get copied into ROLLBACK Tablespace first. Then delete operation get performed. That is why when you type ROLLBACK after deleting table, you can get back the data (The system get it for you from the Rollback Tablespace) TRUNCATE TRUNCATE removes all rows from a table. The operation cannot be rolled back. TRUNCATE is a DDL command. No triggers will be fired. Conditions like WHERE clause cannot be used with it. TRUNCATE is faster than DELETE. Note: when you issue a TRUNCATE command, it removes data directly without copying it into the Rollback Tablespace. So it is faster than DELETE. Also because of the same reason the data dele...