Ask the Expert

How can I insert multiple rows in a DB2 table?

How can I insert multiple rows in a DB2 table? Our system is currently on the sixth version. Please advise.

    Requires Free Membership to View

Well, one way is to issue multiple INSERT statements, one for each row. But I don't think that is what you are asking. If you are looking for a way to insert multiple rows into a DB2 table using one INSERT statement, that is possible using a SELECT within the insert. For example:


Of course, you better make sure that the columns being selected from TABLE2 "match up" with the columns of the TABLE1. But what if you wish to insert multiple rows into a table and that data is not already in another DB2 table. In that case, you should use the LOAD utility. DB2 uses the LOAD utility to bulk load multiple rows into a table and it will be more efficient than a series of INSERT statements. Information on how to use the LOAD utility can be found in the IBM DB2 V7 manual named "Utility Guide and Reference" (SC26-9945) which can be downloaded from the IBM web site for free.


This was first published in December 2002

There are Comments. Add yours.

TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to: