Results 1 to 5 of 5
  1. #1
    Join Date
    Apr 2004
    Posts
    190

    Unanswered: 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

  2. #2
    Join Date
    May 2003
    Location
    USA
    Posts
    5,737
    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

  3. #3
    Join Date
    Apr 2004
    Posts
    190
    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?

  4. #4
    Join Date
    May 2003
    Location
    USA
    Posts
    5,737
    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

  5. #5
    Join Date
    Aug 2001
    Location
    UK
    Posts
    4,650
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •