Click here to monitor SSC
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
SSCrazy Eights
SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)

Group: General Forum Members
Points: 8323 Visits: 11577
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
Hall of Fame
Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)

Group: General Forum Members
Points: 3494 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
Mr or Mrs. 500
Mr or Mrs. 500 (597 reputation)Mr or Mrs. 500 (597 reputation)Mr or Mrs. 500 (597 reputation)Mr or Mrs. 500 (597 reputation)Mr or Mrs. 500 (597 reputation)Mr or Mrs. 500 (597 reputation)Mr or Mrs. 500 (597 reputation)Mr or Mrs. 500 (597 reputation)

Group: General Forum Members
Points: 597 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
SSCertifiable
SSCertifiable (5.8K reputation)SSCertifiable (5.8K reputation)SSCertifiable (5.8K reputation)SSCertifiable (5.8K reputation)SSCertifiable (5.8K reputation)SSCertifiable (5.8K reputation)SSCertifiable (5.8K reputation)SSCertifiable (5.8K reputation)

Group: General Forum Members
Points: 5786 Visits: 7137
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
SSCrazy Eights
SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)

Group: General Forum Members
Points: 8323 Visits: 11577
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
SSCertifiable
SSCertifiable (5.8K reputation)SSCertifiable (5.8K reputation)SSCertifiable (5.8K reputation)SSCertifiable (5.8K reputation)SSCertifiable (5.8K reputation)SSCertifiable (5.8K reputation)SSCertifiable (5.8K reputation)SSCertifiable (5.8K reputation)

Group: General Forum Members
Points: 5786 Visits: 7137
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
Hall of Fame
Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)

Group: General Forum Members
Points: 3494 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.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)

Group: General Forum Members
Points: 2258 Visits: 372
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
SSCrazy
SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)

Group: General Forum Members
Points: 2595 Visits: 3898
Very good ?

M&M
Stuart Davies
Stuart Davies
SSCarpal Tunnel
SSCarpal Tunnel (4.5K reputation)SSCarpal Tunnel (4.5K reputation)SSCarpal Tunnel (4.5K reputation)SSCarpal Tunnel (4.5K reputation)SSCarpal Tunnel (4.5K reputation)SSCarpal Tunnel (4.5K reputation)SSCarpal Tunnel (4.5K reputation)SSCarpal Tunnel (4.5K reputation)

Group: General Forum Members
Points: 4485 Visits: 4549
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 question

There 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