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


I have a question about oracle


I have a question about oracle

Author
Message
fastformation01
fastformation01
Forum Newbie
Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)

Group: General Forum Members
Points: 7 Visits: 4
Which one is faster delete/truncate? Why?
-------------------------------------------------------------------
Sydney Web Design Companies
Cheap Web Design Sydney
PaulB-TheOneAndOnly
PaulB-TheOneAndOnly
SSCertifiable
SSCertifiable (5.5K reputation)SSCertifiable (5.5K reputation)SSCertifiable (5.5K reputation)SSCertifiable (5.5K reputation)SSCertifiable (5.5K reputation)SSCertifiable (5.5K reputation)SSCertifiable (5.5K reputation)SSCertifiable (5.5K reputation)

Group: General Forum Members
Points: 5511 Visits: 4639
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.
RossRoss
RossRoss
Old Hand
Old Hand (337 reputation)Old Hand (337 reputation)Old Hand (337 reputation)Old Hand (337 reputation)Old Hand (337 reputation)Old Hand (337 reputation)Old Hand (337 reputation)Old Hand (337 reputation)

Group: General Forum Members
Points: 337 Visits: 763
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
PaulB-TheOneAndOnly
PaulB-TheOneAndOnly
SSCertifiable
SSCertifiable (5.5K reputation)SSCertifiable (5.5K reputation)SSCertifiable (5.5K reputation)SSCertifiable (5.5K reputation)SSCertifiable (5.5K reputation)SSCertifiable (5.5K reputation)SSCertifiable (5.5K reputation)SSCertifiable (5.5K reputation)

Group: General Forum Members
Points: 5511 Visits: 4639
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.
RossRoss
RossRoss
Old Hand
Old Hand (337 reputation)Old Hand (337 reputation)Old Hand (337 reputation)Old Hand (337 reputation)Old Hand (337 reputation)Old Hand (337 reputation)Old Hand (337 reputation)Old Hand (337 reputation)

Group: General Forum Members
Points: 337 Visits: 763

Can be? It is always faster. See my previous post for details.


I'm just quoting the official Oracle documentation, see the link.
PaulB-TheOneAndOnly
PaulB-TheOneAndOnly
SSCertifiable
SSCertifiable (5.5K reputation)SSCertifiable (5.5K reputation)SSCertifiable (5.5K reputation)SSCertifiable (5.5K reputation)SSCertifiable (5.5K reputation)SSCertifiable (5.5K reputation)SSCertifiable (5.5K reputation)SSCertifiable (5.5K reputation)

Group: General Forum Members
Points: 5511 Visits: 4639
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 :-D

_____________________________________
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.
Lynn Pettis
Lynn Pettis
SSC-Forever
SSC-Forever (40K reputation)SSC-Forever (40K reputation)SSC-Forever (40K reputation)SSC-Forever (40K reputation)SSC-Forever (40K reputation)SSC-Forever (40K reputation)SSC-Forever (40K reputation)SSC-Forever (40K reputation)

Group: General Forum Members
Points: 40364 Visits: 38567
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?

Cool
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)
alan.jeskins-powell-1134784
alan.jeskins-powell-1134784
Forum Newbie
Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)

Group: General Forum Members
Points: 4 Visits: 74
As PaulB mentioned, in OracleTRUNCATE is a DDL operation.
Oracle implicitly commits DDL opeations so a truncate cannot be rolled back.
PaulB-TheOneAndOnly
PaulB-TheOneAndOnly
SSCertifiable
SSCertifiable (5.5K reputation)SSCertifiable (5.5K reputation)SSCertifiable (5.5K reputation)SSCertifiable (5.5K reputation)SSCertifiable (5.5K reputation)SSCertifiable (5.5K reputation)SSCertifiable (5.5K reputation)SSCertifiable (5.5K reputation)

Group: General Forum Members
Points: 5511 Visits: 4639
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.
Lynn Pettis
Lynn Pettis
SSC-Forever
SSC-Forever (40K reputation)SSC-Forever (40K reputation)SSC-Forever (40K reputation)SSC-Forever (40K reputation)SSC-Forever (40K reputation)SSC-Forever (40K reputation)SSC-Forever (40K reputation)SSC-Forever (40K reputation)

Group: General Forum Members
Points: 40364 Visits: 38567
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.

Cool
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)
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