Batch update data

Source: Internet
Author: User

Today, developers want to update a batch of data, and it has not been updated for a long time. After finding me, I found the information on the Internet and found that the rowid method is the fastest updated. refer to the following article to record the update.

Dave article:


Original SQL:

update t_canhe_member_info a set a.id_card = (select b.id_card from BBB_EEE b                                                      where a.member_no = b.member_no)                                   where a.join_year = ‘2014‘ ;


Batch update of PL/SQL blocks:

Declare cursor cur is select. id_card, B. rowid row_id from bbb_eee A, t_canhe_member_info B where. member_no = B. member_no and B. join_year = '000000' order by B. rowid; --- if the table data volume is not large, you do not need to use order by rowid v_counter number; v_jishu number; -- count the number of updates
Begin v_counter: = 0; v_jishu: = 0; for row in cur loop update t_canhe_member_info set id_card = row. id_card where rowid = row. row_id; v_counter: = v_counter + 1; v_jishu: = v_jishu + 1; if (v_counter> = 1000) then commit; -- submit v_counter: = 0; end if; end loop; commit; dbms_output.put_line ('updated '| v_jishu |! '); End;

Batch update data

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.