Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/76.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql 如何使用merge into语句更新表的所有值_Sql_Oracle - Fatal编程技术网

Sql 如何使用merge into语句更新表的所有值

Sql 如何使用merge into语句更新表的所有值,sql,oracle,Sql,Oracle,如何使用merge into语句将源表中的所有值更新到目标表中 我想做的是: merge into src_table using (select * from dest) dest_table on (<some_condition>) when matched then update set src_table.* = dest_table.* where <condition> 我在谷歌上没有找到任何与此相关的东西。我知道可以使用execute immediate

如何使用merge into语句将源表中的所有值更新到目标表中

我想做的是:

merge into src_table
using (select * from dest) dest_table
on (<some_condition>)
when matched then update set src_table.* = dest_table.*
where <condition>
我在谷歌上没有找到任何与此相关的东西。我知道可以使用execute immediate样式语句来实现这一点,但我正在寻找更好的方法。

可以使用pl/sql来实现 或者您可以使用alter table;
您必须明确指定要更新的每一列,除了on子句中使用的那些列之外——它们无法更新。那么为什么不使用alter rename呢?
for src in ( select * from B ) loop
  update A set ROW = src where A.id = src.id; 
end loop; 
alter table your_table
rename to
   your_new_table;