Data Warehousing Community Forum
February 09, 2012, 12:54:31 pm
Home
Help
Search
Login
Register
Data Warehousing Community Forum
>
Databases
>
Oracle
>
Difference between Truncate and Delete?
Pages: [
1
]
Go Down
« previous
next »
Print
Author
Topic: Difference between Truncate and Delete? (Read 1432 times)
Sipra
Founder
Reputation: +59/-0
Offline
Posts: 323
Am the King...
Difference between Truncate and Delete?
«
on:
June 19, 2007, 02:59:02 pm »
Hi all.
Almost all the beginners/experts will atleast confuse a little bit while answering this question.
Similarly I had it a long time back.
Truncate
is a DDL command and
Delete
is a DML command.
After execution of DDL statements commit performs implicitly. That is why your changes are committed automatically when ever you perform a DDL statement ( Create,Alter,Drop,
Truncate
,rename, etc).
DML statements does not commit your changes. You have to commit explicitly inorder to save your changes. Examples of DML commands are select, insert, update,
Delete
etc.
Simply to say - DML statements can be rollbacked where DDL are autocommit.
Please share if you have any inputs also....
Logged
Sipra
Founder
www.dwforum.net
Whoever
Administrator
Reputation: +34/-0
Offline
Posts: 124
Re: Difference between Truncate and Delete?
«
Reply #1 on:
July 17, 2007, 03:10:17 pm »
DELETE
is used to remove specific rows (or all the rows from a table) by using Where clause, however
TRUNCATE
is used to remove all the rows from the table in which we can't use this.
Logged
If most people said what’s on their minds, they’d be speechless.
Raj2007
DW Apprentice
Reputation: +3/-0
Offline
Posts: 25
Lightning for DW Forum
Re: Difference between Truncate and Delete?
«
Reply #2 on:
July 24, 2007, 01:51:40 pm »
TRUNCATE
is faster as it is a DDL statement and no rollback segment needed.
And data cannot be retrieved in normal conditions since DDL has no explicit commit is required.
DELETE
is a bit slower as it is a DML Statement and rollback segment is required.
Selective data can be deleted using where condition and commit needs to be done to complete the transaction.
Logged
unknown
DW Apprentice
Reputation: +8/-0
Offline
Posts: 44
Re: Difference between Truncate and Delete?
«
Reply #3 on:
January 19, 2008, 11:40:18 pm »
Quote from: Raj2007 on July 24, 2007, 01:51:40 pm
TRUNCATE
is faster
DELETE
is a bit slower
Why Truncate is faster than Delete ?
Logged
Thanks
Unknown
Sipra
Founder
Reputation: +59/-0
Offline
Posts: 323
Am the King...
Re: Difference between Truncate and Delete?
«
Reply #4 on:
January 21, 2008, 11:02:54 am »
Deleting a table is logged operation, so the deletion of each row gets logged in the transaction log, which makes it slow.
Truncate table also deletes all the rows in a table, but it won’t log the deletion of each row, instead it logs the de-allocation of the data pages of the table, which makes it faster.
And we need to remember all the time, that
Truncat[e]
'ing a table can't be rolled back.
Logged
Sipra
Founder
www.dwforum.net
samishta
DW Fresher
Reputation: +2/-0
Offline
Posts: 17
Re: Difference between Truncate and Delete?
«
Reply #5 on:
May 29, 2008, 12:32:52 am »
Delete command deletes the rows one by one. The records are logged. You can easily rollback on the delete statement. While the truncate simply truncates the whole of table and releases space. Thus truncate i believe is more efficient.
Delete is usually used when we ought to be selective about the records we delete.
Logged
Arvind
DW Apprentice
Reputation: +10/-0
Offline
Posts: 78
Re: Difference between Truncate and Delete?
«
Reply #6 on:
June 22, 2011, 11:41:53 am »
There is one more difference between these two -
TRUNCATE
command resets the High Water Mark for the table but
DELETE
does not.
So TRUNCATE operations on table are much faster.
Logged
regards,
Arvind
Pages: [
1
]
Go Up
Print
« previous
next »
Jump to:
Please select a destination:
-----------------------------
General Category
-----------------------------
=> Introductions
=> Anouncements & News
=> Suggestions
=> General Discussion
=> Job Opportunities
-----------------------------
Data Warehousing
-----------------------------
=> Data Warehousing Concepts
=> Data Modeling
-----------------------------
Databases
-----------------------------
=> Oracle
===> PL/SQL
=> Microsoft SQL Server
=> IBM DB2
=> Teradata
-----------------------------
ETL Tools
-----------------------------
=> Informatica
===> Installation & Configuration
=> Data Stage
=> Ab Initio
=> Oracle Warehouse Builder
=> DTS/SSIS
-----------------------------
Reporting Tools
-----------------------------
=> Business Objects
=> Cognos
=> Crystal Reports
=> Hyperion
=> Brio
=> Microstrategy
-----------------------------
Operating Systems
-----------------------------
=> UNIX / Linux
===> Unix Shell Scripting
=> Windows
-----------------------------
Other Technologies & Tools
-----------------------------
=> JAVA