Blog

SQL Difference between delete, drop and truncat

SQL

SQL Difference between delete, drop and truncat

Delete

Drop

Truncate

It is a DML command (Data Manipulation Language)

It is a DDL command (Data  Definition Language)

It is a DDL command (Data  Definition Language).

DELETE FROM TableName;

DROP TABLE table_name;

TRUNCATE TABLE table_name;

Can use Where condition to delete a particular row from a table.

Cannot use Where condition.

Cannot use Where condition.

With the help of the DELETE command, we can either delete all the rows in one go or can delete rows one by one. i.e., we can use it as per the requirement or the condition using the Where clause. It is comparatively slower than the TRUNCATE command.

It is used to drop the whole table. With the help of the DROP command we can drop (delete) the whole structure in one go i.e. it removes the named elements of the schema. By using this command the existence of the whole table is finished.

t is used to delete all the rows of a relation (table) in one go. With the help of the “TRUNCATE” command, we can’t delete the single row as here WHERE clause is not used. By using this command the existence of all the rows of the table is lost. It is comparatively faster than the delete command as it deletes all the rows fastly.