Log in
::
Register
::
Not logged in
Home
Tags
Articles
Editorials
Stairways
Forums
Scripts
Videos
Blogs
QotD
Books
Ask SSC
SQL Jobs
Training
Authors
About us
Contact us
Newsletters
Write for us
Recent Posts
Recent Posts
Popular Topics
Popular Topics
Home
Search
Members
Calendar
Who's On
Home
»
SQL Server 2005
»
Working with Oracle
»
I have a question about oracle
I have a question about oracle
Rate Topic
Display Mode
Topic Options
Author
Message
fastformation01
fastformation01
Posted Monday, February 06, 2012 4:56 AM
Forum Newbie
Group: General Forum Members
Last Login: Monday, February 06, 2012 4:54 AM
Points: 3,
Visits: 4
Which one is faster delete/truncate? Why?
-------------------------------------------------------------------
Sydney Web Design Companies
Cheap Web Design Sydney
Post #1247217
PaulB-TheOneAndOnly
PaulB-TheOneAndOnly
Posted Monday, February 06, 2012 6:44 AM
Hall of Fame
Group: General Forum Members
Last Login: Yesterday @ 3:56 PM
Points: 3,016,
Visits: 4,469
fastformation01 (2/6/2012)
Which one is faster delete/truncate? Why?
Assuming you are talking about deleting the whole population of a table it doesn't matter if it's Oracle, SQL Server, DB2 or whatever other RDBMS truncate will always be faster.
In the particular case of Oracle, truncate is not a DML but a pure DDL operation that resets the High Watermark of the table. Truncate statements in Oracle do not generate redo logs therefore, this is an instantaneous process - in SQL Server, truncate statements are minimally logged.
_____________________________________
Pablo (Paul) Berzukov
Author of
Understanding Database Administration
available at Amazon and other bookstores.
Disclaimer: Advice is provided to the best of my knowledge but no implicit or explicit warranties are provided. Since the advisor explicitly encourages testing any and all suggestions on a test non-production environment advisor should not held liable or responsible for any actions taken based on the given advice.
Post #1247302
Ross.M
Ross.M
Posted Wednesday, May 02, 2012 3:48 AM
SSC Veteran
Group: General Forum Members
Last Login: 2 days ago @ 5:03 AM
Points: 215,
Visits: 335
Removing rows with the TRUNCATE statement can be faster than removing all rows with the DELETE statement, especially if the table has numerous triggers, indexes, and other dependencies.
http://docs.oracle.com/cd/B19306_01/server.102/b14200/statements_10006.htm
Post #1293696
PaulB-TheOneAndOnly
PaulB-TheOneAndOnly
Posted Wednesday, May 02, 2012 4:59 AM
Hall of Fame
Group: General Forum Members
Last Login: Yesterday @ 3:56 PM
Points: 3,016,
Visits: 4,469
rossss (5/2/2012)
Removing rows with the TRUNCATE statement can be faster than removing all rows with the DELETE statement...
Can be? It is always faster. See my previous post for details.
_____________________________________
Pablo (Paul) Berzukov
Author of
Understanding Database Administration
available at Amazon and other bookstores.
Disclaimer: Advice is provided to the best of my knowledge but no implicit or explicit warranties are provided. Since the advisor explicitly encourages testing any and all suggestions on a test non-production environment advisor should not held liable or responsible for any actions taken based on the given advice.
Post #1293718
Ross.M
Ross.M
Posted Wednesday, May 02, 2012 5:07 AM
SSC Veteran
Group: General Forum Members
Last Login: 2 days ago @ 5:03 AM
Points: 215,
Visits: 335
Can be? It is always faster. See my previous post for details.
I'm just quoting the official Oracle documentation, see the link.
Post #1293723
PaulB-TheOneAndOnly
PaulB-TheOneAndOnly
Posted Wednesday, May 02, 2012 3:10 PM
Hall of Fame
Group: General Forum Members
Last Login: Yesterday @ 3:56 PM
Points: 3,016,
Visits: 4,469
rossss (5/2/2012)
Can be? It is always faster. See my previous post for details.
I'm just quoting the official Oracle documentation, see the link.
It is always faster
_____________________________________
Pablo (Paul) Berzukov
Author of
Understanding Database Administration
available at Amazon and other bookstores.
Disclaimer: Advice is provided to the best of my knowledge but no implicit or explicit warranties are provided. Since the advisor explicitly encourages testing any and all suggestions on a test non-production environment advisor should not held liable or responsible for any actions taken based on the given advice.
Post #1294221
Lynn Pettis
Lynn Pettis
Posted Wednesday, May 02, 2012 3:13 PM
SSC-Insane
Group: General Forum Members
Last Login: Yesterday @ 9:17 PM
Points: 21,832,
Visits: 27,855
PaulB-TheOneAndOnly (2/6/2012)
fastformation01 (2/6/2012)
Which one is faster delete/truncate? Why?
Assuming you are talking about deleting the whole population of a table it doesn't matter if it's Oracle, SQL Server, DB2 or whatever other RDBMS truncate will always be faster.
In the particular case of Oracle, truncate is not a DML but a pure DDL operation that resets the High Watermark of the table. Truncate statements in Oracle do not generate redo logs therefore, this is an instantaneous process - in SQL Server, truncate statements are minimally logged.
Question. We know that TRUNCATE TABLE in SQL Server can be rolled back if inside a transaction. How about in Oracle?
Lynn Pettis
For better assistance in answering your questions, click here
For tips to get better help with Performance Problems, click here
For Running Totals and its variations, click here
or
when working with partitioned tables
For more about Tally Tables, click here
For more about Cross Tabs and Pivots, click here
and
here
Managing Transaction Logs
SQL Musings from the Desert
Fountain Valley SQL
(My Mirror Blog)
Post #1294222
alan.jeskins-powell-1134784
alan.jeskins-powell-1134784
Posted Thursday, May 03, 2012 12:49 AM
Forum Newbie
Group: General Forum Members
Last Login: Thursday, May 31, 2012 5:27 AM
Points: 2,
Visits: 70
As PaulB mentioned, in OracleTRUNCATE is a DDL operation.
Oracle implicitly commits DDL opeations so a truncate cannot be rolled back.
Post #1294369
PaulB-TheOneAndOnly
PaulB-TheOneAndOnly
Posted Thursday, May 03, 2012 2:26 PM
Hall of Fame
Group: General Forum Members
Last Login: Yesterday @ 3:56 PM
Points: 3,016,
Visits: 4,469
Lynn Pettis (5/2/2012)
Question. We know that TRUNCATE TABLE in SQL Server can be rolled back if inside a transaction. How about in Oracle?
Can't rollback TRUNCATE in the Oracle world.
Oracle's TRUNCATE is a DDL operation as opposed to a DML operation; it works at the catalog level reseting the high water mark of the affected table, it generates no redo log at all.
_____________________________________
Pablo (Paul) Berzukov
Author of
Understanding Database Administration
available at Amazon and other bookstores.
Disclaimer: Advice is provided to the best of my knowledge but no implicit or explicit warranties are provided. Since the advisor explicitly encourages testing any and all suggestions on a test non-production environment advisor should not held liable or responsible for any actions taken based on the given advice.
Post #1294961
Lynn Pettis
Lynn Pettis
Posted Thursday, May 03, 2012 2:32 PM
SSC-Insane
Group: General Forum Members
Last Login: Yesterday @ 9:17 PM
Points: 21,832,
Visits: 27,855
PaulB-TheOneAndOnly (5/3/2012)
Lynn Pettis (5/2/2012)
Question. We know that TRUNCATE TABLE in SQL Server can be rolled back if inside a transaction. How about in Oracle?
Can't rollback TRUNCATE in the Oracle world.
Oracle's TRUNCATE is a DDL operation as opposed to a DML operation; it works at the catalog level reseting the high water mark of the affected table, it generates no redo log at all.
I'm wondering if this why people think the TRUNCATE TABLE in SQL Server can't be rolled back?
Thanks for the info, I'll tuck it away for future reference.
Lynn Pettis
For better assistance in answering your questions, click here
For tips to get better help with Performance Problems, click here
For Running Totals and its variations, click here
or
when working with partitioned tables
For more about Tally Tables, click here
For more about Cross Tabs and Pivots, click here
and
here
Managing Transaction Logs
SQL Musings from the Desert
Fountain Valley SQL
(My Mirror Blog)
Post #1294963
« Prev Topic
|
Next Topic »
Permissions
You
cannot
post new topics.
You
cannot
post topic replies.
You
cannot
post new polls.
You
cannot
post replies to polls.
You
cannot
edit your own topics.
You
cannot
delete your own topics.
You
cannot
edit other topics.
You
cannot
delete other topics.
You
cannot
edit your own posts.
You
cannot
edit other posts.
You
cannot
delete your own posts.
You
cannot
delete other posts.
You
cannot
post events.
You
cannot
edit your own events.
You
cannot
edit other events.
You
cannot
delete your own events.
You
cannot
delete other events.
You
cannot
send private messages.
You
cannot
send emails.
You
may
read topics.
You
cannot
rate topics.
You
cannot
vote within polls.
You
cannot
upload attachments.
You
may
download attachments.
You
cannot
post HTML code.
You
cannot
edit HTML code.
You
cannot
post IFCode.
You
cannot
post JavaScript.
You
cannot
post EmotIcons.
You
cannot
post or upload images.
Copyright © 2002-2013 Simple Talk Publishing. All Rights Reserved.
Privacy Policy.
Terms of Use.
Report Abuse.