我需要从一个包含几百万行的表中更新两列。做这件事最有效的方法是什么?
它将是这样的:
update my_table set column_one = to_date('11/11/11', 'RR/MM/DD'),
column_two = to_date('11/11/11', 'RR/MM/DD');或者这样:
update my_table set column_one = to_date('11/11/11', 'RR/MM/DD');
update my_table set column_two = to_date('11/11/11', 'RR/MM/DD');还是有更好的方法?
发布于 2016-01-26 22:00:07
更新具有百万行的表的最有效方法是根本不执行update操作,而是使用更新值创建一个新表。
发布于 2016-01-26 23:00:28
如果您不想创建新表,只需将其分成块即可。
update my_table set column_one = to_date('11/11/11', 'RR/MM/DD'),
column_two = to_date('11/11/11', 'RR/MM/DD')
where rownum < 1000
AND column_one <> to_date('11/11/11', 'RR/MM/DD')
AND column_two <> to_date('11/11/11', 'RR/MM/DD');@Incognito的答案可能更好。如果你的意思是“高效”是花在编写代码上的时间更少,那就试试这种方法。
https://stackoverflow.com/questions/35015404
复制相似问题