Difference between DELETE, TRUNCATE and DROP

DELETE

1- DELETE is a DML commands.
2- DELETE command is used to remove particular rows from a table.
3- We can use conditions(WHERE clause) in DELETE.
4- Delete activates a trigger because the operation are logged individually.
5- DELETE is slower than truncate because, it keeps logs. 
6- Rollback is possible.

Example:   DELETE from EMPLOYEE WHERE id =10;

TRUNCATE

1- TRUNCATE is a DDL commands.
2- TRUNCATE commands remove all rows from a table.
3- You can't use conditions(WHERE clause) in TRUNCATE.
4- TRUNCATE TABLE can not activate a trigger because the operation does not log individual row deletions.
5- TRUNCATE is faster, because it doesn't keep any logs.
6- Rollback is not possible(If Transaction is done, means COMMITED, then we can not rollback TRUNCATE command).

Example: TRUNCATE EMPLOYEE(Table name);

DROP

1- DROP is a DDL commands.
2- The DROP command removes all rows with table structure.
3- Rollback is not possible.

Example: DROP EMPLOYEE(Table name);

Posted on by