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 > A Load that Deletes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-07-07, 07:42
JDionne JDionne is offline
Registered User
 
Join Date: Aug 2002
Location: Charlotte NC
Posts: 663
A Load that Deletes

I am having a hard time finding information regarding the Load command and the critieria that it uses to know that it has to do a delete.

I know that the load did do a delete, but I dont know why.

Number of rows read = 292518
Number of rows skipped = 0
Number of rows loaded = 292518
Number of rows rejected = 0
Number of rows deleted = 77264
Number of rows committed = 292518

Can anyone point me to the correct documentation so that I can get a better understanding of what is going on?

Regards
__________________
------------
And back to SQL Server....I always find my way home
View my Linkedin profile
Reply With Quote
  #2 (permalink)  
Old 12-07-07, 07:48
JDionne JDionne is offline
Registered User
 
Join Date: Aug 2002
Location: Charlotte NC
Posts: 663
I found this online

"INSERT and DELETE privilege on the table when the load utility is invoked in REPLACE mode"

this is my code
Code:
load from $IXF_LOCATION of ixf replace into CENSTG.STG_RKEM_MOVE_TBL nonrecoverable
From what I can see online it looks like i have a primary key violation on the table that is causing the deletes. Am I thinking correctly?
__________________
------------
And back to SQL Server....I always find my way home
View my Linkedin profile
Reply With Quote
  #3 (permalink)  
Old 12-07-07, 08:54
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
Not necessarily a primary key - any unique constraint violation will cause LOAD to delete duplicate rows after the build phase.
Reply With Quote
  #4 (permalink)  
Old 12-07-07, 09:04
JDionne JDionne is offline
Registered User
 
Join Date: Aug 2002
Location: Charlotte NC
Posts: 663
...Just like an Index...which I have just deleted and am reloading now. I will let you know the results.
__________________
------------
And back to SQL Server....I always find my way home
View my Linkedin profile
Reply With Quote
  #5 (permalink)  
Old 12-07-07, 09:24
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,196
You used the REPLACE option. This means that existing rows are deleted.
__________________
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
  #6 (permalink)  
Old 12-07-07, 10:31
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
Other constraint violations also cause rows to be deleted. For example, if you have a column with "CHECK ( col IN ('A', 'B', 'C') )", then DB2 must delete the row if the value in such a column is 'D'. Otherwise, you would have inconsistencies in the database.
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
  #7 (permalink)  
Old 12-07-07, 10:46
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
I would think that in the case of violated check or referential constraints, no deletes would happen during the load; instead, the table would be put into the check pending state upon the load completion, and it would be the administrator's task to deal with that.
Reply With Quote
  #8 (permalink)  
Old 12-07-07, 10:49
sathyaram_s sathyaram_s is offline
Super Moderator
 
Join Date: Aug 2001
Location: UK
Posts: 4,534
Knut, IIRC, during the delete phase of a load command, only unique key violations are deleted.

After load, SET INTEGRITY has to be run on a table that has check constraints and referential constraints. By specifying an exception table, the constraint violating rows are deleted from the main table and placed in the exception table. If no exception table is specified, the table continues in the check pending status.

Please correct me if I am wrong.

Thanks


Sathyaram


Quote:
Originally Posted by stolze
Other constraint violations also cause rows to be deleted. For example, if you have a column with "CHECK ( col IN ('A', 'B', 'C') )", then DB2 must delete the row if the value in such a column is 'D'. Otherwise, you would have inconsistencies in the database.
__________________
Visit the new-look IDUG Website , register to gain access to the excellent content.
Reply With Quote
  #9 (permalink)  
Old 12-07-07, 15:14
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
You're right and I'm wrong (again). SET INTEGRITY has to be used to bring a table out of check pending state by verifying RI/check constrainsts. Unique constraints are handled during index rebuild in load already.
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
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