Inserting Data Records

To initially populate a DB2 table with data, the INSERT statement can be used to store one data record at a time. The statement can be targeted to insert data directly into a base table, or a view can be used instead. If a view is being used as the target, remember that it is the base table where the actual data is being stored.

Every row populated using the INSERT statement must adhere to table-check constraints, data type validation, dynamic (trigger) constraints, and referential integrity constraints. An SQL error will occur if any of these conditions are violated during the processing of the INSERT statement.

NOTE

Remember that you must have the necessary view or table privileges to perform an INSERT statement.

To illustrate ...

Get DB2® Universal Database™ v8 Application Development Certification Guide, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.