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 > db2 load .... insert into

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-10-11, 15:39
redwolf redwolf is offline
Registered User
 
Join Date: Apr 2004
Posts: 179
db2 load .... insert into

Hello - Could someone please tell me what the load utility does in cases where rows have been modified in a table after an export has been done? You issue the load command with insert into, how are those modified rows handled ?

Thanks
Reply With Quote
  #2 (permalink)  
Old 10-10-11, 16:13
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,196
I think there may be some misunderstanding on your part.

If you do an export, the data is stored in a flat file (you specify the file name in the export command). Then when you do a load (or import) at some later time interval, the flat file with the name you specify is used as input and the rows are added to the table you specify.
__________________
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
  #3 (permalink)  
Old 10-10-11, 16:30
redwolf redwolf is offline
Registered User
 
Join Date: Apr 2004
Posts: 179
Right, I'm aware of this. My question is does the data in the file overwrite the changes in the table if you load the file into the same table at a later time using db2 load?
Reply With Quote
  #4 (permalink)  
Old 10-10-11, 16:43
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,196
If you load the data back into the same table?
  • If there is no unique index (or PK) on the table, it will add the row, leaving the old row in place.
  • If there is a unique index or PK on the table, then the new row will be rejected during the load process (it will show up in the Deleted count in the output) becaue it will violate a unique constraint.
  • Rows do not get updated using the insert commnand.
__________________
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
  #5 (permalink)  
Old 10-10-11, 16:45
sathyaram_s sathyaram_s is offline
Super Moderator
 
Join Date: Aug 2001
Location: UK
Posts: 4,534
Quote:
Originally Posted by redwolf View Post
Right, I'm aware of this. My question is does the data in the file overwrite the changes in the table if you load the file into the same table at a later time using db2 load?
REPLACE INTO overwrites the changes. To make it clear, REPLACE options removes all rows from the table and inserts the rows from the file.

INSERT appends data to the table. If a primary or unique key violation is found, the row is deleted from the table. You can capture the deleted rows and save in an EXCEPTION table.

Read the LOAD command description in the manuals.
__________________
Visit the new-look IDUG Website , register to gain access to the excellent content.
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