How to import a CSV file on db2

Written by usha dadighat
  • Share
  • Tweet
  • Share
  • Email

The DB2 database system created by IBM operates on Window and Linux machines and can import file types such as comma separated value (CSV) files. This allows you to create your data in a separate program and upload it directly into your DB2 tables to save time. DB2 offers a few options for uploading files. The command centre provides a direct option, but importing CSV files via SQL commands allows you to manipulate or change the data before you add it to the table.

Skill level:
Moderate

Other People Are Reading

Instructions

    SQL Command

  1. 1

    Open the SQL code for your DB2 database and connect to the database.

  2. 2

    Type "IMPORT FROM "sample_file.csv" OF DEL INSERT INTO your_table (attribute 1, attribute 2)" into the code replacing "sample_file.csv" with the path and name of your CSV file, "your_table" with the name of the table you want to import the data into and "attribute1" and "attribute2" with the names of the columns. You may import as many attributes as you need as long as you separate them with commas.

  3. 3

    Run the code and check your table to see that the data from the CSV file has imported correctly.

    Command Center

  1. 1

    Click the "Start" icon, open "All Programs," open the "IBM DB2" folder and click "Command Center."

  2. 2

    Click "File" or "Command Center" in the top toolbar menu. Click "Import," then click "..." to browse for the file. Click "OK" to complete the process. You can also right-click with the left-hand navigation tree and click "Create from Import" to access the same options.

  3. 3

    Refresh the table and check the data for any errors.

Tips and warnings

  • Make sure columns in the CSV file match the columns in the DB2 table before you import.

Don't Miss

Filter:
  • All types
  • Articles
  • Slideshows
  • Videos
Sort:
  • Most relevant
  • Most popular
  • Most recent

No articles available

No slideshows available

No videos available

By using the eHow.co.uk site, you consent to the use of cookies. For more information, please see our Cookie policy.