简体   繁体   中英

Bulk update in Oracle12c

I have a situation like to update a column(all rows) in a table having 150 million records.

Creation of duplicate table with updates and dropping of previous table is the best way but there is no available disk space to hold the duplicate table. So how to perform the update in less time? Partitions are there on the table. I am using oracle 12c

The cleanest approach is NOT updating the table, but creating a new table with the new column of updated rows. For instance, let's say I needed to update a column called old_value with the max of some value, instead of updating the old_table one does:

create new_table as select foo, bar, max(old_value) from old_table; 
drop table old_table; 
rename new_table as old_table. 

If you need even more speed, you can do this creation using a parallel query with nologging thereby generating very little redo and no undo logs. More details can be ascertained here: https://asktom.oracle.com/pls/asktom/f?p=100:11:0::NO::P11_QUESTION_ID:6407993912330

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM