本人菜鸟求大牛帮忙修改sql下可以更快更新50w条数据,用的oracle

declare
cursor csr_dept
is
select company_name,BUSINESS_REG_NUM,ORG_CODE,CORE_ID
from t_core_company where core_id is null for update of CORE_ID;
row_dept csr_dept%rowtype;
t varchar2(35);
begin
--for循环
for row_dept in csr_dept loop
--取同义词
select QUERY_GET_COMPANY_UUID(row_dept.company_name,row_dept.business_reg_num,row_dept.org_code) into t from dual;
update t_core_company set CORE_ID=t where current of csr_dept;

     end loop;
   commit;

end;

QUERY_GET_COMPANY_UUID(row_dept.company_name,row_dept.business_reg_num,row_dept.org_code)这个函数的代码?

取同义词 为何不与游标查询语句一起用。

update t_core_company set CORE_ID=QUERY_GET_COMPANY_UUID(company_name,business_reg_num,org_code) where core_id is null 你在备份库上测试一下呗。

会不会是QUERY_GET_COMPANY_UUID()这个函数连接远程数据库慢导致呢?
循环50w次连接远程数据库服务器估计需要挺长时间的,是不是可以考虑把连接远程数据库服务器的代码放到循环之外?
注:对oracle的dblink机制不是很熟悉,不知道这种情况是不是会连接50w次

如果更新相同字段内容值,批量更新应该好些吧,或者50w数据分成50 * 1000 ,每次批量更新1000,循环50次。还有一些更新慢的原因,可能是行锁或连接的问题吧!