in this article i am goig to show you what is difference between delete and truncate and
drop command.
1->Delete
Delete command mostly use for delete single row or multiple row or delete all the row in
table.
take an examples ..
delete stud .
Will delete all rows in stud table.
now ,
delete from stud where condition..
will delete single or multiple record.
it is faster slower than truncate.
we can rollback .
2->Truncate.
Will delete all the data from table .
we can not specify where condition.
Faster than delete .
we can't rollback until we use transaction.
truncate table tablename
3-> drop
to delete the table also with data.
drop table tablename.
rollback but in transaction.
remember one thing once we committed we wont undo record or table in delete or truncate or
drop command.
begin tran
delete fee
rollback tran
begin tran
delete from stud where id=104
drop table stud
delete will keep your identity as well.
second time entry will tale last id number where as in truncate that will start from 1.
0 comments: