你可以試試這個任何一個甲骨文
正常的更新
UPDATE
INCIDENT
SET
INCIDENT.OWNER_ID =
(SELECT
INCIDENTDESCRIPTION.USER_ID
FROM
INCIDENTDESCRIPTION
WHERE
INCIDENT.OWNER_ID = INCIDENTDESCRIPTION.USER_ID)
WHERE
EXISTS
(SELECT
INCIDENTDESCRIPTION.USER_ID
FROM
INCIDENTDESCRIPTION
WHERE
INCIDENT.OWNER_ID = INCIDENTDESCRIPTION.USER_ID);
使用內嵌視圖(如果它是由甲骨文認爲更新)
注意:如果你面對一個非關鍵保存行錯誤添加一個索引來解決相同的問題,使其更新
UPDATE
(SELECT
INCIDENT.OWNER_ID AS OLD,
INCIDENTDESCRIPTION.USER_ID AS NEW
FROM
INCIDENT
INNER JOIN
INCIDENTDESCRIPTION
ON INCIDENT.INCI_ID = INCIDENTDESCRIPTION.INCI_ID) T
SET
T.OLD = T.NEW;
使用合併
MERGE INTO
INCIDENT
USING
(SELECT
T1.ROWID AS RID,
T2.INCI_ID
FROM
INCIDENT T1
INNER JOIN
INCIDENTDESCRIPTION T2
ON INCIDENT.INCI_ID = INCIDENTDESCRIPTION.INCI_ID)
ON
(ROWID = RID)
WHEN MATCHED
THEN
UPDATE SET INCIDENT.INCI_ID = INCIDENTDESCRIPTION.INCI_ID;
Oracle是否'update'支持'join'?你的語法看起來更像MySQL。 –
@GordonLinoff一個很大的否......但有一些技巧,例如在MERGE USING子句或在線視圖 – SriniV
中使用連接,請顯示錶格模式,示例數據和預期結果。 – OldProgrammer