If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Delete with commit

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-25-05, 16:50
oracle08821 oracle08821 is offline
Registered User
 
Join Date: Feb 2004
Posts: 24
Question Delete with commit

Hi All,

I am trying to delete some unwanted records from a table in db2 and want to commint in between the records like say for every 1000 recrods I want to do a commit on the table just to avoid the filling of the logs.

Thanks in advance.

Srinivas.
__________________
Thanks
Srinivas chityala
Reply With Quote
  #2 (permalink)  
Old 01-25-05, 16:56
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
Srinivas,
You cannot do that. All you can do is use the WHERE clause and run
the delete multiple times.

Instead of: DELETE FROM MyTable
You can try:
DELETE FROM MyTable where myUniqueCol between (0 and 10000)
DELETE FROM MyTable where myUniqueCol between (10000 and 20000)
DELETE FROM MyTable where myUniqueCol between (20000 and 30000)
DELETE FROM MyTable where myUniqueCol between (30000 and 40000)
DELETE FROM MyTable where myUniqueCol between (40000 and 50000)
etc.

HTH

Andy
Reply With Quote
  #3 (permalink)  
Old 01-25-05, 17:00
oracle08821 oracle08821 is offline
Registered User
 
Join Date: Feb 2004
Posts: 24
Thanks Andy for the quick respond. I also thought of another way like
delete from table_name where col_name in (select col_name from table_name
fetch first 1000 rows only);

commit;

and repeat the same for multiple times.

Thanks
Srinivas
__________________
Thanks
Srinivas chityala
Reply With Quote
  #4 (permalink)  
Old 01-25-05, 19:11
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,196
Alter table table-name ACTIVATE NOT LOGGED INITIALLY;
Delete from table-name where ...;
commit;

You must execute the above script with auto-commit turned off (+c). The delete will not be logged. Make sure you have a backup, because in the event of a system failure the table will be corrupted.
__________________
M. A. Feldman
IBM Certified DBA on DB2 for Linux, UNIX, and Windows
IBM Certified DBA on DB2 for z/OS and OS/390
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On