Search Tutorials

Sunday, 20 October 2013

Difference between Delete, Truncate and Drop command in SQL

In this tutorial, we have given simple difference between delete, truncate and drop command in SQL language.

Delete:if we use delete command in a query than it simply deletes all data in a table not structure of the table.

SQL> delete table_name;

and all data can recover using rollback command.

SQL> rollback;

Truncate: if we use truncate command in a query than it deletes all data permanently and not structure of the table.

SQL> truncate table table_name;

and data can not recover using rollback command.

Another difference between delete and truncate command: if we are using auto increment variable in a table and we run delete command,after delete command if we insert any row than it simply increments the value of auto increment variable but in truncate command it starts value from one.

Drop: if we use drop command in a query than it deletes all data and structure of the table.