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 > Bulk Delete

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-07-07, 06:24
d_mohan81 d_mohan81 is offline
Registered User
 
Join Date: Feb 2007
Posts: 31
Bulk Delete

Hi,
Can you suggest methods to do bulk delete.? The table contain 7 million rows in that.

Regards
Mohan
__________________
Regards
Mohan
Reply With Quote
  #2 (permalink)  
Old 03-07-07, 06:33
sathyaram_s sathyaram_s is offline
Super Moderator
 
Join Date: Aug 2001
Location: UK
Posts: 4,534
IMPORT FROM /dev/null of del replace into tablename

or

ALTER TABLE tablename NOT LOGGED INITIALLY WITH EMPTY TABLE

The first one is a command and cannot be issued from a SQL Interface like JDBC.

The second one is SQL but requires higher privileges on the table.

Sathyaram
__________________
Visit the new-look IDUG Website , register to gain access to the excellent content.
Reply With Quote
  #3 (permalink)  
Old 03-07-07, 07:44
grofaty grofaty is offline
Registered User
 
Join Date: Jan 2003
Posts: 1,570
Quote:
Originally Posted by sathyaram_s
IMPORT FROM /dev/null of del replace into tablename
Hi, this command deletes all rows from table.

On Windows there is:
import from nul: of del replace into tablename.

Hope this helps,
Grofaty
Reply With Quote
  #4 (permalink)  
Old 03-07-07, 13:44
Peter.Vanroose Peter.Vanroose is offline
Registered User
 
Join Date: Sep 2004
Location: Belgium
Posts: 1,079
Also on z/OS this is indeed the fastest way to bulk delete:
- "LOAD REPLACE" from an empty dataset.
or
- REORG ... DISCARD FROM table WHEN (0 = 0)

As can be expected, REORG ... DISCARD WHEN is also the most efficient way to bulk delete only part of the table rows: use the condition which you would put in "DELETE ... WHERE" as the "REORG ... DISCARD ... WHEN" condition. (stage-1 / sargable only)
__________________
--_Peter Vanroose,
__IBM Certified Database Administrator, DB2 9 for z/OS
__IBM Certified Application Developer
__ABIS Training and Consulting
__http://www.abis.be/

Last edited by Peter.Vanroose; 03-07-07 at 13:56.
Reply With Quote
  #5 (permalink)  
Old 03-08-07, 06:22
d_mohan81 d_mohan81 is offline
Registered User
 
Join Date: Feb 2007
Posts: 31
Hi,
I want to delete a praticular(eg:empid) 10 lakh rows .The total rows in that table contain 35 lakh rows. Can I use the Load command or is there any specific command is there ..?
__________________
Regards
Mohan
Reply With Quote
  #6 (permalink)  
Old 03-08-07, 07:59
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
You can either:
  1. send one (or more) DELETE statements, or
  2. you export the data you want to keep, empty/truncate the table and then import/load the previously exported data.

Maybe it is an option for you to use NOT LOGGED INITIALLY when doing the DELETE. That avoids logging, but has same side effects that may not be an option in your environment.
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
  #7 (permalink)  
Old 03-08-07, 11:30
Wim Wim is offline
Registered User
 
Join Date: Nov 2004
Posts: 1,279
What are "lakh rows" ?

Quote:
Originally Posted by d_mohan81
Hi,
I want to delete a praticular(eg:empid) 10 lakh rows .The total rows in that table contain 35 lakh rows. Can I use the Load command or is there any specific command is there ..?
__________________
With kind regards . . . . . SQL Server 2000/2005/2008/2008 R2 Earned beers: 16
Wim
Beware of bugs in the above code; I have only proved it correct, not tried it. -- Donald Knuth
Grabel's Law: 2 is not equal to 3 -- not even for very large values of 2.
Pat Phelan's Law: 2 very definitely CAN equal 3 -- in at least two programming languages
Reply With Quote
  #8 (permalink)  
Old 03-08-07, 12:16
sathyaram_s sathyaram_s is offline
Super Moderator
 
Join Date: Aug 2001
Location: UK
Posts: 4,534
It is a different(????) number(!!) system where 10 lakhs = 1 million ...
So, the OP is talking about 1 m and 3.5 m records

Sathyaram
__________________
Visit the new-look IDUG Website , register to gain access to the excellent content.
Reply With Quote
  #9 (permalink)  
Old 03-08-07, 15:01
Peter.Vanroose Peter.Vanroose is offline
Registered User
 
Join Date: Sep 2004
Location: Belgium
Posts: 1,079
Quote:
Originally Posted by d_mohan81
I want to delete a praticular(eg:empid) 10 lakh rows .The total rows in that table contain 35 lakh rows. Can I use the Load command or is there any specific command is there ..?
On z/OS, use "REORG ts DISCARD FROM table WHEN (EMPID = value)"
See http://publibz.boulder.ibm.com/cgi-b...20040209165609
__________________
--_Peter Vanroose,
__IBM Certified Database Administrator, DB2 9 for z/OS
__IBM Certified Application Developer
__ABIS Training and Consulting
__http://www.abis.be/
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