SQL Insert through UNION ALL

Views with tables connected through the use of UNION ALL have been supported for a number of releases. SELECT, DELETE, and UPDATE operators have been allowed as long as DB2 could determine the table to which the corresponding command was applied.

In DB2, support for the INSERT operator has been extended to views with UNION ALL, as long as the following conditions hold:

  • The expressions have the same data types.

  • A constraint exists on at least one column that can be used to uniquely identify where a row should be inserted and the constraint ranges are nonoverlapping.

  • Views defined in this fashion also support UPDATE operations as long as the column being changed does not violate the constraint for that column. In this ...

Get DB2® Version 8: The Official Guide 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.