Results 1 to 6 of 6
  1. #1
    Join Date
    Dec 2012
    Posts
    3

    Unanswered: DB2 data load help

    I have to load data in non-empty DB2 table. My Input load file has few thousand records and I am certain that my input file has some records with most recent values and my DB2 table has old / outdated values. I have to replace outdated records. example below,

    DB2 Table:

    S.No Product_ID Price
    1. SKU120 10.00
    2. SKU124 19.29
    3. SKU147 34.49
    4. SKU198 99.99
    + Few million records...

    Input File (This will contain only updated values / new records):

    S.No Product_ID Price
    1. SKU120 23.49
    2. SKU234 33.50 (new product)
    + few hundred records.

    I want to replace Price of SKU120 in DB2 with input file, at the same time I want to keep #2,#3, #4 and other million records and append SKU234(New product) to the DB2 table. Is this possible? If so, what utility / load parameters I need to use.

  2. #2
    Join Date
    Aug 2008
    Location
    Toronto, Canada
    Posts
    2,367
    IMPORT command with INSERT_UPDATE option:
    Adds rows of imported data to the target table, or updates existing rows (of the target table) with matching primary keys.

  3. #3
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1
    If the task is as simple as you describe, you can use the IMPORT command with the INSERT_UPDATE option. Alternatives might be using a staging table and a MERGE statement or, with a recent DB2 version, an INGEST utility that is available with the DB2 10.1 client and is somewhat backward-compatible.
    ---
    "It does not work" is not a valid problem statement.

  4. #4
    Join Date
    Dec 2012
    Posts
    3

    Thanks!

    Thanks Mam. Can this be used along with DB2 LOAD utility?

  5. #5
    Join Date
    May 2003
    Location
    USA
    Posts
    5,737
    If you only have a few thousand rows to add/update, the import utility works fine. Check the Command Reference manual for LOAD and IMPORT to see what options each supports.
    M. A. Feldman
    IBM Certified DBA on DB2 for Linux, UNIX, and Windows
    IBM Certified DBA on DB2 for z/OS and OS/390

  6. #6
    Join Date
    Dec 2012
    Posts
    3

    Thanks.

    Marcus my everyday input dataset will contain 2k to 3k new/updated records.

    Thank you all. I will give a try. Have a good weekend.

Tags for this Thread

Posting Permissions

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