Pages

Monday, June 27, 2016

Difference between drop , delete , truncate in DB


hi guys 

in this post i will talk about the difference between delete statements in SQL 
lets go



Drop statement :


drop is Data Definition Language Statement used in Level of database objects such as table
and to drop table this mean you will delete structure and data in table
So drop used to delete structure and data 

But delete and truncate used to delete data only without structure but difference is 


Delete Statement :

delete data only and log it in ldf this mean you can rollback and undo after execute delete statement 
but it is overhead and affect performance because you need log before delete 


truncate Statement :

truncate remove data only like delete but truncate not log data and you can not undo but it faster than delete . you can not truncate data that have foreign key and when use truncate reset identity

No comments:

Post a Comment