Efficient way to update all rows in a table

后端 未结 6 1971
执笔经年
执笔经年 2020-12-17 08:27

I have a table with a lot of records (could be more than 500 000 or 1 000 000). I added a new column in this table and I need to fill a value for every row in the column, us

6条回答
  •  忘掉有多难
    2020-12-17 09:03

    Might not work you for, but a technique I've used a couple times in the past for similar circumstances.

    created updated_{table_name}, then select insert into this table in batches. Once finished, and this hinges on Oracle ( which I don't know or use ) supporting the ability to rename tables in an atomic fashion. updated_{table_name} becomes {table_name} while {table_name} becomes original_{table_name}.

    Last time I had to do this was for a heavily indexed table with several million rows that absolutely positively could not be locked for the duration needed to make some serious changes to it.

提交回复
热议问题