How Many Ways Insert Rows into DB2 Tables

Here are three ideas to insert rows into DB2 Tables.

Idea#1: SQL Insert query

Using DML INSERTs gets data into the DB2 tables, but it is not a feasible option for large amounts of data. The LOAD utility is needed for populating tables with large amounts of data.

Idea#2: Utilities

For removing data from a DB2 table, we can use DML DELETEs, but doing so is not optimal for large amounts of data. For unloading data, better options are DSNTIAUL, UNLOAD, and REORG DISCARD or REORG UNLOAD EXTERNAL.

Idea#3: Load Utility

The LOAD utility is used to load one or more tables of a table space. This utility loads records into the tables and builds or extends any indexes defined on them. If the table space already contains data, you can either add the new data to the existing data or replace the existing data. The loaded data is processed by any edit or validation routine associated with the table and any field procedure associated with any column of the table.

Db2 Load Utility

  • The LOAD utility will load data coming from a sequential data set into one or more tables in the same table space. Because data is coming in from a non-DB2 source, all integrity checking must be performed: entity integrity, referential integrity, and check integrity.
  • The output from LOAD DATA consists of a loaded table space or partition, a discard file of rejected records, and a summary report of errors encountered during processing. (This report is generated only if you specify ENFORCE CONSTRAINTS or if the LOAD involves unique indexes.).

Related: DB2 Jobs and Career options


Author: Srini

Experienced software developer. Skills in Development, Coding, Testing and Debugging. Good Data analytic skills (Data Warehousing and BI). Also skills in Mainframe.