Page 1 of 1

delete entire rows and load the table instead of truncate

Posted: Mon Dec 01, 2008 12:42 am
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?

Posted: Mon Dec 01, 2008 8:27 am
by chulett
Oracle Enterprise stage? Use the OPEN command for that.

Posted: Mon Dec 01, 2008 2:25 pm
by ray.wurlod
Resist stupid requirements. DELETE all rows is transactional, and takes a long time. TRUNCATE is non-transactional and is fast.

Posted: Mon Dec 01, 2008 2:39 pm
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

Posted: Mon Dec 01, 2008 4:25 pm
by ray.wurlod
"The business has a rule..."

Posted: Mon Dec 01, 2008 6:12 pm
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.

Posted: Mon Dec 01, 2008 6:13 pm
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.

Posted: Tue Dec 02, 2008 12:35 am
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"

Posted: Tue Dec 02, 2008 12:46 am
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

Posted: Tue Dec 02, 2008 8:01 am
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

Posted: Tue Dec 02, 2008 8:04 am
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.

Posted: Tue Dec 02, 2008 9:33 pm
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.

Posted: Wed Dec 03, 2008 12:15 am
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.

Posted: Wed Dec 03, 2008 1:03 am
by chulett
You must have missed the "nologging is ignored" part, but ok - whatever works for you.