ORA-01779 on SQL update tips
Oracle Tips by Burleson Consulting
Updated August 9, 2015
Question: I cannot get
this update to run and I get the ORA-01779 error:
ORA-01779: cannot modify a
column which maps to a non key-preserved table.
src.object_name AS src_name,
src.object_type AS src_type,
tgt.object_name AS tgt_name,
src.object_id = tgt.object_id)
tgt_name = src_name,
tgt_type = src_type;
Answer: Using the
utility, the Oracle docs note this on the
ORA-01779: cannot modify a column which maps to a non
Cause: An attempt was made to
insert or update columns of a join view which map to a non-key-preserved
Action: Modify the underlying base tables
In your case, the ORA-01779 results because the update statement is malformed (by using an in-line view on
two tables) and you want to issue the SQL update directly against
one individual table, not the two tables that are specified in your DML
Views can be updated under the right conditions, in which case, the
ORA-01779 will not be an issue.
Some views support inserts while at the same time rejecting updates.
Whether a view can be updated depends on the keys from the underlying table
The answer to the question of whether or not a particular view is updatable
is directly related to the difference between simple and complex
Generally, DML can be performed against the view if the base table is
DML is not allowed in situations where duplicate data exists but is
suppressed, like with the DISTINCT operator. Attempting an update
using DISTINCT is not allowed because Oracle has no way of knowing which
record should be updated.
Thus, with complex views, some columns may be updated and some may not.
This is decided by the table from which the column comes and if there is a
primary key or key-preserved value that can be determined.
The ORA-01779 will result if you have inaccurately assessed your table for
primary key or key-preserved value integrity.
Follow the jump for more