ORA-01779: unable to modify column corresponding to non-key-value save table

Problem Description

 Bug Report -
SQL Error: ORA-01779: cannot modify column
01779. 00000 - "cannot modify a column which maps to a non key-preserved table"
*Cause: An attempt was made to insert or update columns of a join view which
           map to a non-key-preserved table.
*Action: Modify the underlying base tables directly.

The reason for this error is that in the result of the subquery, the demo_t2 table id used to update demo_t1 is not unique, so that one row in the updated object test1 may correspond to many rows in test2, so oracle does not know how to update

For example, fname A fmoney '20' in demo_t1 may correspond to fname A fmoney '100' and ifname A fmoney '200' in demo_t2, so it cannot be updated. 

Solution

Delete duplicate data and add a primary key to demo_t2

ALTER TABLE DEMO_T2 ADD PRIMARY KEY(FNAME);

Try again, the update is successful

Guess you like

Origin blog.csdn.net/qq_39997939/article/details/122894411