Unix Technical Forum

Restricting the number of rows in delete statement

This is a discussion on Restricting the number of rows in delete statement within the DB2 forums, part of the Database Server Software category; --> Folks: I am trying to find out what is the best way to restrict the number of rows deleted ...


Go Back   Unix Technical Forum > Database Server Software > DB2

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-26-2008, 03:36 PM
Nikhil
 
Posts: n/a
Default Restricting the number of rows in delete statement

Folks:

I am trying to find out what is the best way to restrict the number of
rows deleted in a single statement (so as to not blow out the logs). I
can repeatedly run the delete until there are no more rows to be
deleted.

I have implemented a solution that selects the Primary Key columns
along with row_number() over() in a temp table and then deletes based
on the row_number range. I was wondering if there is an
alternative/better way of doing this...

Thanks in advance.

Regards,
Nikhil
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-26-2008, 03:36 PM
Richard D. Latham
 
Posts: n/a
Default Re: Restricting the number of rows in delete statement

Blair Adamache <badamache@2muchspam.yahoo.com> writes:

> You don't have to use row_number in v8 - this syntax will work:
>
> delete from address where name in
> (select name from address
> order by name
> fetch first 1 row only)


Cool.

Do we support the new goodies on Common Table Expressions too ?

--
#include <disclaimer.std> /* I don't speak for IBM ... */
/* Heck, I don't even speak for myself */
/* Don't believe me ? Ask my wife :-) */
Richard D. Latham lathamr@us.ibm.com
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-26-2008, 03:36 PM
Blair Adamache
 
Posts: n/a
Default Re: Restricting the number of rows in delete statement

I don't know.

You're probably best to install v8 Fixpak 3 and experiment (unless Serge
steps in with some advice).

Richard D. Latham wrote:

> Blair Adamache <badamache@2muchspam.yahoo.com> writes:
>
>
>>You don't have to use row_number in v8 - this syntax will work:
>>
>>delete from address where name in
>> (select name from address
>> order by name
>> fetch first 1 row only)

>
>
> Cool.
>
> Do we support the new goodies on Common Table Expressions too ?
>


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 02-26-2008, 03:42 PM
Serge Rielau
 
Posts: n/a
Default Re: Restricting the number of rows in delete statement

Yes, no restrictions. This is V8 GA function btw.
Here is DB2 FP<soon>
DELETE FROM
(SELECT name FROM address ORDER BY name FETCH FIRST 1 ROW ONLY);

Come to my talk at DBM Tech in Vegas for more info :-)

Cheers
Serge


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 03:34 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
www.UnixAdminTalk.com