Difference between Clear and Truncate

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
besco
Participant
Posts: 33
Joined: Wed Jun 09, 2004 1:44 am

Difference between Clear and Truncate

Post by besco »

I'd just seen In ORAOCI8, in update action, two choices :
- clear table then insert rows
- truncate table then insert rows

What are differences ?
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

'Truncate' means truncate. The table is logically cleared almost instantly.

'Clear' means delete all records. This is transactional and can take time, rollback, etc etc.
-craig

"You can never have too many knives" -- Logan Nine Fingers
besco
Participant
Posts: 33
Joined: Wed Jun 09, 2004 1:44 am

Post by besco »

Ok, thanks
acb
Participant
Posts: 6
Joined: Mon Mar 08, 2004 8:50 am

Re: Difference between Clear and Truncate

Post by acb »

besco wrote:I'd just seen In ORAOCI8, in update action, two choices :
- clear table then insert rows
- truncate table then insert rows

What are differences ?
Besco,

Both the Update actions' functionality is the same.
But, the former action deletes the contents of the table and adds
the new rows, with slower performance because of transaction
logging. Whereas, the later truncates the table without transaction logging and hence faster performance.

P.S. Refer Datastage's help.

Regards,
Bhanu.
richdhan
Premium Member
Premium Member
Posts: 364
Joined: Thu Feb 12, 2004 12:24 am

Post by richdhan »

Hi,

I just want to add to Bhanu's comments.

Clear/Delete: For every delete an entry is made in the transaction log.
Advantage:You have the posibility of rollback
Disadvantage:Slower compared to Truncate since it has to make an entry in the transaction log

Truncate: No entry is made in the transaction log.
Advantage:Faster since no entry is made in the transaction log
Disadvantage:You cannot rollback since it is a Data Definition command.

HTH

Rich
AGStafford
Premium Member
Premium Member
Posts: 30
Joined: Thu Jan 16, 2003 2:51 pm

Post by AGStafford »

To add to Rich's comment.

Since truncate is a DDL command, more authority is required. In our shop we have no DDL authority :( and thus must go through a Proc to perform the truncate.

Andrew
Post Reply