Re: Delete Only 50 rows from table
Posted in 2005
jayloub wrote:
> I need to delete a limited number of rows from the table.
> The table contains 50,000.
>
> I only want to delete the records older than a certain date and then
> only 500 at a time.
>
IDS allows for some powerful memory management in UDRs.
What you should be able to do is create a UDR counter()
When counter() is called the first time it initializes to 1. Every
subsequent call increases the return by 1.
That should take care of the counting part.
IDS also supports hints. Not sure how strong such a directive is, but
you should be able to do the following:
CREATE VIEW V(rn) AS (SELECT counter() FROM T /* INDEX .... */)
DELETE FROM V WHERE rn < 500
It's so ugly.. it just may work ;-)
Cheers
Serge
--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab