Truncate the table before inserting into it.

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
Minhajuddin
Participant
Posts: 467
Joined: Tue Mar 20, 2007 6:36 am
Location: Chennai
Contact:

Truncate the table before inserting into it.

Post by Minhajuddin »

Hi all,
I have a scenario where I need to INSERT 17 Million records in a table

I need to truncate the table before inserting these records. i.e. before I insert these 17 Mi records I need to delete all the records from the target table.

I am using an Oracle enterprise stage. Is there a way in which I can truncate the whole table before I insert these records?

Thanks for the help.
Minhajuddin

<a href="http://feeds.feedburner.com/~r/MyExperi ... ~6/2"><img src="http://feeds.feedburner.com/MyExperienc ... lrow.3.gif" alt="My experiences with this DLROW" border="0"></a>
shrey3a
Premium Member
Premium Member
Posts: 234
Joined: Sun Nov 21, 2004 10:41 pm

Post by shrey3a »

In sql before tab use the Truncate statement or crate the sp and call it in sql before tab.


Clear and insert option will take al ot of time i.e. 17m rows.

Thanks
Minhajuddin
Participant
Posts: 467
Joined: Tue Mar 20, 2007 6:36 am
Location: Chennai
Contact:

Post by Minhajuddin »

I am using the Upsert option and in that we don't have any option for truncate.

Is creating a Stored Proc the only option?
Minhajuddin

<a href="http://feeds.feedburner.com/~r/MyExperi ... ~6/2"><img src="http://feeds.feedburner.com/MyExperienc ... lrow.3.gif" alt="My experiences with this DLROW" border="0"></a>
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

You can also pass the truncate command in the OPEN/CLOSE command of the enterprise stage.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
Minhajuddin
Participant
Posts: 467
Joined: Tue Mar 20, 2007 6:36 am
Location: Chennai
Contact:

Post by Minhajuddin »

Hi DSguru,

Can I pass an SQL like

truncate MyTable

in the open command of the enterprise stage. And does truncating of a table before inserting has any impact on the performance?
Minhajuddin

<a href="http://feeds.feedburner.com/~r/MyExperi ... ~6/2"><img src="http://feeds.feedburner.com/MyExperienc ... lrow.3.gif" alt="My experiences with this DLROW" border="0"></a>
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Yes. You can pass TRUNCATE command in the OPEN/CLOSE command. It will be the most performant operation.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
Minhajuddin
Participant
Posts: 467
Joined: Tue Mar 20, 2007 6:36 am
Location: Chennai
Contact:

Post by Minhajuddin »

Thanks for the Help :D
Minhajuddin

<a href="http://feeds.feedburner.com/~r/MyExperi ... ~6/2"><img src="http://feeds.feedburner.com/MyExperienc ... lrow.3.gif" alt="My experiences with this DLROW" border="0"></a>
Post Reply