SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


TRUNCATE TABLE and ROLLBACK TRAN


TRUNCATE TABLE and ROLLBACK TRAN

Author
Message
Hugo Kornelis
Hugo Kornelis
SSCoach
SSCoach (19K reputation)SSCoach (19K reputation)SSCoach (19K reputation)SSCoach (19K reputation)SSCoach (19K reputation)SSCoach (19K reputation)SSCoach (19K reputation)SSCoach (19K reputation)

Group: General Forum Members
Points: 19163 Visits: 12426
I wanted to comment that this question is superfluous, that everyone knows this. But.....

At the time of writing:
"Incorrect answers: 56% (52)"
And 34% of them are for "you can never rollback a truncate table statement"

.
.
.
.
.
.

Picks up jaw from floor.


Hugo Kornelis, SQL Server MVP
Visit my SQL Server blog: http://sqlblog.com/blogs/hugo_kornelis
vk-kirov
vk-kirov
SSCarpal Tunnel
SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)

Group: General Forum Members
Points: 4364 Visits: 4408
Hugo Kornelis (2/6/2012)

And 34% of them are for "you can never rollback a truncate table statement"

Maybe they are Oracle refugees? Hehe http://www.sqlservercentral.com/articles/Raw+Materials/71108/
Brigadur
Brigadur
Right there with Babe
Right there with Babe (771 reputation)Right there with Babe (771 reputation)Right there with Babe (771 reputation)Right there with Babe (771 reputation)Right there with Babe (771 reputation)Right there with Babe (771 reputation)Right there with Babe (771 reputation)Right there with Babe (771 reputation)

Group: General Forum Members
Points: 771 Visits: 27695
Nice and important question. This issue is coming up time to time when discussing differences of delete and truncate operation.
Stewart "Arturius" Campbell
Stewart "Arturius" Campbell
SSCoach
SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)

Group: General Forum Members
Points: 17558 Visits: 7423
vk-kirov (2/6/2012)
Hugo Kornelis (2/6/2012)

And 34% of them are for "you can never rollback a truncate table statement"

Maybe they are Oracle refugees? Hehe http://www.sqlservercentral.com/articles/Raw+Materials/71108/


A TRUNCATE can be rolled back in Oracle as well....

____________________________________________
Space, the final frontier? not any more...
All limits henceforth are self-imposed.
“libera tute vulgaris ex”
Hugo Kornelis
Hugo Kornelis
SSCoach
SSCoach (19K reputation)SSCoach (19K reputation)SSCoach (19K reputation)SSCoach (19K reputation)SSCoach (19K reputation)SSCoach (19K reputation)SSCoach (19K reputation)SSCoach (19K reputation)

Group: General Forum Members
Points: 19163 Visits: 12426
Stewart "Arturius" Campbell (2/6/2012)
vk-kirov (2/6/2012)
Hugo Kornelis (2/6/2012)

And 34% of them are for "you can never rollback a truncate table statement"

Maybe they are Oracle refugees? Hehe http://www.sqlservercentral.com/articles/Raw+Materials/71108/


A TRUNCATE can be rolled back in Oracle as well....


I've never used Oracle, so I can't speak from experience - but the official Oracle documentation disagrees with you:
http://docs.oracle.com/cd/B28359_01/server.111/b28286/statements_10007.htm

"Caution:
You cannot roll back a TRUNCATE TABLE statement, nor can you use a FLASHBACK TABLE statement to retrieve the contents of a table that has been truncated."


Hugo Kornelis, SQL Server MVP
Visit my SQL Server blog: http://sqlblog.com/blogs/hugo_kornelis
Stewart "Arturius" Campbell
Stewart "Arturius" Campbell
SSCoach
SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)

Group: General Forum Members
Points: 17558 Visits: 7423
Hugo Kornelis (2/6/2012)
Stewart "Arturius" Campbell (2/6/2012)
vk-kirov (2/6/2012)
Hugo Kornelis (2/6/2012)

And 34% of them are for "you can never rollback a truncate table statement"

Maybe they are Oracle refugees? Hehe http://www.sqlservercentral.com/articles/Raw+Materials/71108/


A TRUNCATE can be rolled back in Oracle as well....


I've never used Oracle, so I can't speak from experience - but the official Oracle documentation disagrees with you:
http://docs.oracle.com/cd/B28359_01/server.111/b28286/statements_10007.htm

"Caution:
You cannot roll back a TRUNCATE TABLE statement, nor can you use a FLASHBACK TABLE statement to retrieve the contents of a table that has been truncated."


Wonder when this was changed?
Granted I haven't worked in Oracle itself since 7b...

____________________________________________
Space, the final frontier? not any more...
All limits henceforth are self-imposed.
“libera tute vulgaris ex”
vk-kirov
vk-kirov
SSCarpal Tunnel
SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)

Group: General Forum Members
Points: 4364 Visits: 4408
Hugo Kornelis (2/6/2012)
Stewart "Arturius" Campbell (2/6/2012)
A TRUNCATE can be rolled back in Oracle as well....


I've never used Oracle, so I can't speak from experience - but the official Oracle documentation disagrees with you:
http://docs.oracle.com/cd/B28359_01/server.111/b28286/statements_10007.htm

"Caution:
You cannot roll back a TRUNCATE TABLE statement, nor can you use a FLASHBACK TABLE statement to retrieve the contents of a table that has been truncated."

In addition, a TRUNCATE TABLE statement is considered as a DDL operation in Oracle. DDL operations cannot be committed or rolled back explicitly in Oracle. http://docs.oracle.com/cd/E11882_01/server.112/e26088/statements_1001.htm
Data Definition Language (DDL) Statements

Oracle Database implicitly commits the current transaction before and after every DDL statement.
The DDL statements are:
ALTER
...
TRUNCATE

ako58
ako58
SSCrazy
SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)

Group: General Forum Members
Points: 2406 Visits: 415
CREATE TABLE t(id INT IDENTITY, i INT)
BEGIN TRAN
INSERT INTO t VALUES (4),(2),(3)
SELECT * FROM t
ROLLBACK TRAN
SELECT * FROM t
INSERT INTO t VALUES (4),(2),(3)
SELECT * FROM t

where is rollback?
M&M
M&M
SSCertifiable
SSCertifiable (6.2K reputation)SSCertifiable (6.2K reputation)SSCertifiable (6.2K reputation)SSCertifiable (6.2K reputation)SSCertifiable (6.2K reputation)SSCertifiable (6.2K reputation)SSCertifiable (6.2K reputation)SSCertifiable (6.2K reputation)

Group: General Forum Members
Points: 6225 Visits: 3913
Very good ?

M&M
Stuart Davies
Stuart Davies
SSCertifiable
SSCertifiable (7.5K reputation)SSCertifiable (7.5K reputation)SSCertifiable (7.5K reputation)SSCertifiable (7.5K reputation)SSCertifiable (7.5K reputation)SSCertifiable (7.5K reputation)SSCertifiable (7.5K reputation)SSCertifiable (7.5K reputation)

Group: General Forum Members
Points: 7500 Visits: 4830
Hugo Kornelis (2/6/2012)
I wanted to comment that this question is superfluous, that everyone knows this. But.....

At the time of writing:
"Incorrect answers: 56% (52)"
And 34% of them are for "you can never rollback a truncate table statement"

.
.
.
.
.
.

Picks up jaw from floor.

It's got better -
Correct answers: 42% (76)
Incorrect answers: 58% (107)
Total attempts: 183

The myth still abounds regrettably

-------------------------------Posting Data Etiquette - Jeff Moden Smart way to ask a questionThere are naive questions, tedious questions, ill-phrased questions, questions put after inadequate self-criticism. But every question is a cry to understand (the world). There is no such thing as a dumb question. ― Carl Sagan I would never join a club that would allow me as a member - Groucho Marx
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search