What is the difference between Delete, Truncate and Drop commands?
HTML-код
- Опубликовано: 11 июл 2022
- 1. Full .NET Interview Course
C# / ASP.NET Core / MVC / API - Top 500 Interview Questions
www.udemy.com/course/csharp-o...
Don't worry if course not helping you, Udemy has 30 days Free Refund Policy.
2. Quick Revision Book (PDF format)
Top 500 .NET Interview Questions - OOPS/ C#/ ASP.Net/ MVC/ SQL /.Net Core /Web API
imojo.in/interviewhappy
50% Discount Applied on above link.
Don't worry if book not helping you, I will return 100% of your money with in 7 days of purchase. Just mail me at anuragrawat123@gmail.com.
My best wishes are with you.
One more difference.
TRUNCATE command reset the identity to its seed value. But DELETE retains the identity and does not reset it to the seed value.
If you use the truncate command data cannot be rollback.
Truncate is a DDL command , it's autocommit.
Hello sir, I got selected in IBM-Pune by watching and practicing through your interview videos. Thank you so much.
Glad my videos helped you cracking interview. Congratulations @saroshfaisalkhan3531. All the very best ;-)
@@interviewhappy Thank you so much Happy Sir... stay happy and healthy..and lots of love for you.
Hi Happy...I have one query, if we write Truncate and Drop statements in transaction. Can it be rollbacked?
Truncate can not Rollback
Rollback operation we can not perfrom in Truncate
Because Truncate is AutoCommit
If we write Command "Delete from Table_name;" Or "Drop Table Table_name;" Then what will be the difference and which one to prefer and why?
Hi Kush, if you write delete then the whole data/ records will be deleted but the table structure will remain there. You can write insert command to put data back. But if you drop then table structure will be gone also. You have to recreate the table again and then insert data there.
@@interviewhappy soryy i meant Truncate table Table_name
This query and delete
I mean difference between delete and truncate command without where clause in delete command
@@KushKumar-ig9ub without where only two differences. Truncate can't be rollbacked. You run it and all data is gone. Delete can be rollbacked. Truncates is fast and its a DDL. Delete is slow and DML. It is recommended to use delete.
@interviewhappy but in the video you mentioned truncate also can be rollback .