Difference between Truncate and Delete

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
lakshmipriya
Participant
Posts: 31
Joined: Tue Jul 13, 2004 5:26 am
Location: chennai
Contact:

Difference between Truncate and Delete

Post by lakshmipriya »

Hi

What is the difference between the DELETE mode and WRITE - TRUNCATE mode. What will be the impact of the same in database.

Can any one help me out on the same.

Thanks in advance
Lakshmi
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Which database? There IS more than one, despite what Oracle bin Larry would have us believe. :lol:

As a general rule, truncate is a fast operation that recovers space formerly occupied by data.

Delete deletes individual records, and the operations are logged in the transaction log. It tends to be a rather slower process than truncate.

If this is not the answer to your question, can you please post a more precise question? For example, you may be asking about menu options in a particular stage type. If so, please provide the stage type name and the actual text of the menu options.

You might also profitably consult the documentation and/or on-line help for that particular stage type.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
lakshmipriya
Participant
Posts: 31
Joined: Tue Jul 13, 2004 5:26 am
Location: chennai
Contact:

Post by lakshmipriya »

Hi

Thanks for your great interest.

In DB2/UDBEnterprise stage as of my knowledge both the truncate and delete option send the commond as Delete, if so how does Truncate option will be more faster than the delete option.

How does it internally works on. Can you put some more light on the same.

Thanks
Lakshmi
roy
Participant
Posts: 2598
Joined: Wed Jul 30, 2003 2:05 am
Location: Israel

Post by roy »

Hi,
I just wanted to point this is a DBA issue rather then DS.
so if no replies simply contact your project's supporting DBA.

IHTH,
Roy R.
Time is money but when you don't have money time is all you can afford.

Search before posting:)

Join the DataStagers team effort at:
http://www.worldcommunitygrid.org
Image
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

My earlier reply was generic; consult DB2 documentation (or DBA) for an explanation of the different working of DELETE and TRUNCATE TABLE. You should be able to tie it in with what I wrote to enhance your understanding of the differences.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
vmcburney
Participant
Posts: 3593
Joined: Thu Jan 23, 2003 5:25 pm
Location: Australia, Melbourne
Contact:

Post by vmcburney »

Truncate can be dangerous. Triggers on the table will not be fired by a truncate, they will be fired by a delete. Changed data capture modules may have problems identifying a truncate. Dependent foreign key relationships can be bypassed by a truncate leaving you with data integrity problems. These are the type of issues you need to discuss with someone who knows the database structure quite well.
Mike
Premium Member
Premium Member
Posts: 1021
Joined: Sun Mar 03, 2002 6:01 pm
Location: Tampa, FL

Post by Mike »

It used to be the case (probably still is) that DB2 doesn't have a TRUNCATE TABLE statement. That explains why DataStage does a DELETE with no WHERE clause under the covers for that option. The closest equivalent to Oracle's TRUNCATE is a LOAD REPLACE with an empty file.

Mike
Post Reply