Loading data by issuing INSERT statements
You can load data into tables is by issuing INSERT statements interactively or by embedding them in application programs.
Procedure
To load data into Db2 tables by issuing the INSERT statement, use one of the following approaches:
What to do next
If you plan to use the INSERT statement to load tables, you should consider the following the implications of doing so:
- If you are inserting a large number of rows, you can also use the LOAD utility. Alternatively, use multiple INSERT statements with predicates that isolate the data that is to be loaded, and then commit after each insert operation.
- When a table, whose indexes are already defined, is populated by using the INSERT statement, both the FREEPAGE and the PCTFREE parameters are ignored. FREEPAGE and PCTFREE are in effect only during a LOAD or REORG operation. For more information, see Reserving free spaces for indexes.
- Set the NOT LOGGED attribute for table spaces when large volumes of data are being inserted with parallel INSERT processes. If the data in the table space is lost or damaged, it can be reinserted from its original source.
- You can load a value for a ROWID column with an INSERT and fullselect only if the ROWID column is defined as GENERATED BY DEFAULT. If you have a table with a column that is defined as ROWID GENERATED ALWAYS, you can propagate non-ROWID columns from a table with the same definition. For more information, see Rules for inserting data into a ROWID column.
- You cannot use an INSERT statement on system-maintained materialized query tables.
- REBUILD-pending (RBDP) status is set on a data-partitioned secondary index if you create the index after you insert a row into a table. In addition, the last partition of the table space is set to REORG-pending (REORP) restrictive status.
- When you insert a row into a table that resides in a partitioned table space and the value of the first column of the limit key is null, the result of the INSERT depends on whether Db2 enforces the limit key of the last partition:
- When Db2 enforces the limit key of the last partition, the INSERT fails (if the first column is ascending).
- When Db2 enforces the limit key of the last partition, the rows are inserted into the first partition (if the first column is descending).
- When Db2 does not enforce the limit key of the last partition, the rows are inserted into the last partition (if the first column is ascending) or the first partition (if the first column is descending).
- Tables spaces using table-controlled partitioning that are large or non-large (any DSSIZE)
- Table spaces using table-controlled or index-controlled partitioning that are large (DSSIZE 4 GB or greater)