Wednesday 18 September 2013

Difference between Delete ,Truncate and Drop command in Sql.

Delete:-

Delete command delete all the rows from the table if you exclude where condition or delete some row from the table if you include where condition.
It does not free the space containing the table.
Use all delete trigger on the table to fire.
It deallocate row by row log transaction so that it is slower that truncate.
Roll back is possible if you use inside transaction.

Truncate:-

Truncate command is used to delete  all the rows from the table .
free the space containing table.
No where clause is used.
No triggers are fired on this operation because no individual log row used.
Roll back is possible if you use inside transaction.

DROP:-


If table is dropped , all the relationships with the tables will no longer be available, the index,triggers,constraint and permission specifications also dropped. If you want to use the table again  it has to be created again with all the thing you required.

No comments:

Post a Comment

Note: only a member of this blog may post a comment.