Problem with Delete

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rajinbits
    New Member
    • Dec 2007
    • 1

    Problem with Delete

    Hello,
    I am facing a problem with DELETE statement. I have to delete around 2 billion records from a table with 150 columns. on execution of the delete statement, it fails after some time with message " Log Space full".

    I am having a log space og 2 GB. But I guess thats proving in sufficient. I am using one indexed column to delete the data. If I use other column as filter statement I have to run the query more than 1000 times.

    Is there any way to overcome this?
  • docdiesel
    Recognized Expert Contributor
    • Aug 2007
    • 297

    #2
    Hi,

    if you want to delete all rows from that table, a "LOAD (client) from empty.file of del replace into my.table" is the fastest way to do.

    If the number of rows to be deleted is far more that those to be preserved, build a temp. table, declare a cursor on your original table and SELECT the rows you want to keep. Then LOAD these from the cursor into the temp. table, and afterwards reverse the LOAD (with replace option).

    If you have to stick to a DELETE statement, there's no other way than to increase the log space and/or do it in several steps, e.g. if you got a date column, set a limit on monthly base. You could also choose to aprox. cut in half the amount of rows to be deleted, time and time again, as long as it takes to run the DELETE successfully. That way you'll learn how many rows/data of that table you may delete with 2GB of log space.

    Regards, Bernd

    Comment

    • db2doubts
      New Member
      • Dec 2007
      • 3

      #3
      Hello,

      If you are a DBA then you just update CFG parameter logsecond -1 then executive the command after completion of that u can reset this CFG

      Comment

      Working...