Oracle 用于从另一个表中的匹配字段更新字段的SQL

Oracle 用于从另一个表中的匹配字段更新字段的SQL,oracle,sql-update,Oracle,Sql Update,我试图使用另一个表中的数据填充一个表中的字段,该表充当查找表,类似于这样,但似乎不起作用,似乎无限期运行 UPDATE table1 t1 SET field=(select field2 FROM table2 t2 WHERE t1.otherfield=t2.otherfield) 是您想要的技巧。在某些情况下,merge语句可能更有效。您还可以尝试以下操作:- merge into table1 t1 using(sele

我试图使用另一个表中的数据填充一个表中的字段,该表充当查找表,类似于这样,但似乎不起作用,似乎无限期运行

UPDATE table1 t1
  SET field=(select field2
               FROM table2 t2
               WHERE t1.otherfield=t2.otherfield)

是您想要的技巧。

在某些情况下,merge语句可能更有效。您还可以尝试以下操作:-

merge into table1 t1
using(select otherfield,field2 from table2)y
on(t1.otherfield=y.otherfield)
when matched then
update set field=y.field2
“似乎无限期地运行”是什么意思?需要更多的背景。
merge into table1 t1
using(select otherfield,field2 from table2)y
on(t1.otherfield=y.otherfield)
when matched then
update set field=y.field2