How to import a CSV file on db2

Updated April 17, 2017

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.

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

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.

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

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

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.

Refresh the table and check the data for any errors.


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

Cite this Article A tool to create a citation to reference this article Cite this Article

About the Author

Usha Dadighat has been writing since 2008. She earned a Bachelor of Science in computer science and a minor in psychology from the Missouri University of Science and Technology in December 2010. She currently works as a software development engineer and has extensive technical writing experience.