delete entire rows and load the table instead of truncate

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
suneyes
Participant
Posts: 82
Joined: Mon Jul 21, 2008 8:42 am

delete entire rows and load the table instead of truncate

Post by suneyes »

I have a business rule that we wont be having truncate option on a production table.
Can I delete entire rows before loading the table instead of truncate in an ORACLE stage.
We can do it as a two step process but,can it be done in a single stage?
sun
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Oracle Enterprise stage? Use the OPEN command for that.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Resist stupid requirements. DELETE all rows is transactional, and takes a long time. TRUNCATE is non-transactional and is fast.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Mike
Premium Member
Premium Member
Posts: 1021
Joined: Sun Mar 03, 2002 6:01 pm
Location: Tampa, FL

Post by Mike »

Business rule? The business users that I've known wouldn't utter any technical jargon like "truncate table".

If your DBAs are concerned about granting truncate privileges, they can always create a stored procedure and grant you access to that.

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

Post by ray.wurlod »

"The business has a rule..."
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
gxhpainter
Premium Member
Premium Member
Posts: 28
Joined: Tue Jul 01, 2008 9:23 am

Post by gxhpainter »

You can issue user defined query ' delete from tablename with nologging" that will do couple of things

1. It will not make log
2. It is very fast compared to normal delete.

Rgds,
Chakradhar.
gxhpainter
Premium Member
Premium Member
Posts: 28
Joined: Tue Jul 01, 2008 9:23 am

Post by gxhpainter »

You can issue user defined query ' delete from tablename with nologging" that will do couple of things

1. It will not make log
2. It is very fast compared to normal delete.

Rgds,
Chakradhar.
suneyes
Participant
Posts: 82
Joined: Mon Jul 21, 2008 8:42 am

Post by suneyes »

gxhpainter wrote:You can issue user defined query ' delete from tablename with nologging" that will do couple of things

1. It will not make log
2. It is very fast compared to normal delete.

Rgds,
Chakradhar.

Hi when I try executing this stmt(with nologging) in oracle..it is giving me an error that "statement not ended properly"
sun
suneyes
Participant
Posts: 82
Joined: Mon Jul 21, 2008 8:42 am

Post by suneyes »

Mike wrote:Business rule? The business users that I've known wouldn't utter any technical jargon like "truncate table".

If your DBAs are concerned about granting truncate privileges, they can always create a stored procedure and grant you access to that.

Mike
I mean to say that,DBA will not be allowing us with a truncate privilage on any production table
sun
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

suneyes wrote:
gxhpainter wrote:You can issue user defined query ' delete from tablename with nologging" that will do couple of things

1. It will not make log
2. It is very fast compared to normal delete.

Rgds,
Chakradhar.
Hi when I try executing this stmt(with nologging) in oracle..it is giving me an error that "statement not ended properly"
:? Two problems here.

1) That syntax is invalid. Remove "with" from the sql.
2) The advice is poor because 'normal' DML like deletes or inserts always log and the 'nologging' is ignored. Never mind the fact that not logging (and thus not having a mechanism to roll-back) kind of defeats the purpose of using a transactional delete.

A couple of references for the curious:

http://www.scribd.com/doc/3633656/Redo-paper-nologging

http://www.jlcomp.demon.co.uk/faq/nologging.html
-craig

"You can never have too many knives" -- Logan Nine Fingers
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

suneyes wrote:
Mike wrote:Business rule? The business users that I've known wouldn't utter any technical jargon like "truncate table".
If your DBAs are concerned about granting truncate privileges, they can always create a stored procedure and grant you access to that.
I mean to say that,DBA will not be allowing us with a truncate privilage on any production table
Pretty unusual to have a need to truncate a core production table. However, as Mike notes, if you really need the ability for a table your DBA can create a stored procedure that can truncate that (or a restricted list) table and grant your user permissions to execute it. Very common solution when you need this functionality.
-craig

"You can never have too many knives" -- Logan Nine Fingers
suneyes
Participant
Posts: 82
Joined: Mon Jul 21, 2008 8:42 am

Post by suneyes »

chulett wrote:
suneyes wrote:
Mike wrote:Business rule? The business users that I've known wouldn't utter any technical jargon like "truncate table".
If your DBAs are concerned about granting truncate privileges, they can always create a stored procedure and grant you access to that.
I mean to say that,DBA will not be allowing us with a truncate privilage on any production table
Pretty unusual to have a need to truncate a core production table. However, as Mike notes, if you really need the ability for a table your DBA can create a stored procedure that can truncate that (or a restricted list) table and grant your user permissions to execute it. Very common solution when you need this functionality.
Hi,
the table in a temporary table for storing data required for some jobs which needs to be truncated and Loaded before we execute these jobs.the DBA part which youve specified needs to be checked with my DBA.
Thanks for the reply.
sun
suneyes
Participant
Posts: 82
Joined: Mon Jul 21, 2008 8:42 am

Post by suneyes »

chulett wrote:
suneyes wrote:
gxhpainter wrote:You can issue user defined query ' delete from tablename with nologging" that will do couple of things

1. It will not make log
2. It is very fast compared to normal delete.

Rgds,
Chakradhar.
Hi when I try executing this stmt(with nologging) in oracle..it is giving me an error that "statement not ended properly"
:? Two problems here.

1) That syntax is invalid. Remove "with" from the sql.
2) The advice is poor because 'normal' DML like deletes or inserts always log and the 'nologging' is ignored. Never mind the fact that not logging (and thus not having a mechanism to roll-back) kind of defeats the purpose of using a transactional delete.

A couple of references for the curious:

http://www.scribd.com/doc/3633656/Redo-paper-nologging

http://www.jlcomp.demon.co.uk/faq/nologging.html

Hi chulet,
Thanks for the info..it worked for me..I am running the job without logging.
sun
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

You must have missed the "nologging is ignored" part, but ok - whatever works for you.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply