Skip to content
Advertisement

Do Changes Made on Table Created by Joining a View and an Another Table Affect Original Table View Based On?

Suppose I have a view created on a table. If I change some record on my view, the original table is also changed too. What if I join this view with an another table and change some records on this result table I got by joining, would original table on which view based also be changed?

Advertisement

Answer

In principle, yes, if the views are constructed in such a way that the underlying tables are updateable through the view. For example, let’s say I have a table named TABLE_1 and create a view VIEW_1 as follows:

If I issue the update statement

Oracle is bright enough to pass the UPDATE through to the underlying table, and TABLE_1 will be updated.

A view of any complexity, however, will most likely contain operations that make the view non-updateable. So let’s say I have the following VIEW_2:

an UPDATE of this view will fail with an ORA-01732: data manipulation operation not legal on this view error. So whether you can update through a view or not very much depends on what operations the view is performing.

db<>fiddle here

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement