How can I insert multiple rows in a DB2 table? Our system is currently on the sixth version. Please advise.
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:
INSERT INTO TABLE1 SELECT C1, C2, C3 FROM TABLE2;
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. http://www-3.ibm.com/software/data/db2/library/
Dig Deeper on IBM DB2 management
Related Q&A from Craig S. Mullins
Our expert suggests that the best way to pass the SAP BW exam is to have hands-on job experience. But that's not all he has to say about ... Continue Reading
To export data from a DB2 table to a flat file, you need to run an export specifying the proper file format. The export utility exports data from a ... Continue Reading
Craig Mullins recommends two specific resources for learning how to create and support Binary Large Objects (BLOB) in DB2. Continue Reading
Have a question for an expert?
Please add a title for your question
Get answers from a TechTarget expert on whatever's puzzling you.