Friday, November 28, 2008

difference between truncate and delete sql command?

Q. What is the difference between truncate and delete sql command?

·        Ans:  Condition can be given in delete command but not in truncate. The DELETE statement does not ask for confirmation. However, the delete operation is not made permanent until the data transaction is committed.

·         DELETE is a DML command. In DELETE we can undo the operation with the ROLLBACK statement if we make a mistake. TRUNCATE is a DDL command and we cannot roll back row removal when using TRUNCATE.

 

·        The TRUNCATE TABLE statement Removes all rows from a table and releases the storage space used by that table.

·        The DELETE statement can also remove all rows from a table, but it does not release storage space.

·        Removing rows with the TRUNCATE statement is faster than removing them with the DELETE because it does not generates the roll back information.

 

No comments: