Interview Questions   Tutorials   Discussions   Programs   

DB2 - Are views updatable or not?

asked mar August 21, 2014 12:25 PM  

Are views updatable or not?


1 Answers

answered By Mswami   0  
Yes, views are updatable based on the below concept.

Updatable Views: In order to update a column in a view, DB2 must not only be able to map the row specified in the view to one row in a base table, it also must be able to map the column to be updated to a column in a base table. Hence all views that are updatable must by definition also be deletable.

An updatable view is a special case of a deletable view. A deletable view becomes an updatable view when at least one of its columns is updatable.

A column of a view is updatable when all of the following rules are true:

  • The view is deletable.
  • The column resolves to a column of a table (not using a dereference operation) and the READ ONLY option is not specified.
  • All the corresponding columns of the operands of a UNION ALL have exactly matching data types (including length or precision and scale) and matching default values if the fullselect of the view includes a UNION ALL.

The following example uses constant values that cannot be updated. However, the view is a deletable view and at least one of its columns is updatable. Therefore, it is an updatable view.

CREATE VIEW updatable_view
(number, current_date, current_time, temperature)
FROM weather.forecast
WHERE number = 300

   add comment

Your answer

Join with account you already have



 Write A Tutorials
Online-Classroom Classes

  1 person following this question

  1 person following this tag

  Question tags

Asked 1 year and 1 month ago ago
Number of Views -179
Number of Answers -1
Last updated
2 years and 2 months ago ago

Ready to start your tutorial with us? That's great! Send us an email and we will get back to you as soon as possible!