In the previous post, we have seen, what is the difference between in “Truncate vs. Delete”?
Actually if we use truncate then we can’t rollback the data, but the question is … What will happen if we use truncate within a transaction, Whether we can rollback or not?.
The following example reveals the answer for our question.
I created a table and inserted a rows, as shown below
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhDl4n9Q4NNd_p0NJmaYk9usgTTZuO-NVWyEUA6N9UtZEhy0-rS8VqCUukvpxvxSgq6-JIXKQVL8zEFB3A21DclkKo_O1g4_fPIL_bmvGabS4QMevDxZ5Xih2sTfjC7eEKk609EfSE9gaU/s200/select3.png)
Actually if we use truncate then we can’t rollback the data, but the question is … What will happen if we use truncate within a transaction, Whether we can rollback or not?.
The following example reveals the answer for our question.
I created a table and inserted a rows, as shown below
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhDl4n9Q4NNd_p0NJmaYk9usgTTZuO-NVWyEUA6N9UtZEhy0-rS8VqCUukvpxvxSgq6-JIXKQVL8zEFB3A21DclkKo_O1g4_fPIL_bmvGabS4QMevDxZ5Xih2sTfjC7eEKk609EfSE9gaU/s200/select3.png)
Then I executed the below Query:
It Returns:
Conclusion:
Truncated Data can be roll backed if it is executed within a transaction
No comments:
Post a Comment
Your comments, Feedbacks and Suggestions are very much valuable to me :)