Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8464977
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T14:54:40+00:00 2026-06-10T14:54:40+00:00

I have 2 options to update a table based on a cursor of a

  • 0

I have 2 options to update a table based on a cursor of a select query.

Say I have this select query:

select id1 from table1

and my update query is :

update table2 set value=1 where table2.id2 = table1.id1

Now the 2 options are:

  1. set a cursor the select query and fetch it in bulk and then fire the update query inside the for all statement.

  2. write update query with the select subquery as:

    update table2 set value=1 where table2.id2 in (select id1 from table1)

which one is better?

Does Oracle internally convert the select subquery in to a bulk collect or does it treat it as a normal cursor?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T14:54:41+00:00Added an answer on June 10, 2026 at 2:54 pm

    First on your question “Does Oracle internally convert the select subquery in to a bulk collect?”
    No. The optimizer calculates a plan and selects the data from the subquery in some appropiate way. There’s no bulk collect involved.

    To your question “which one is better?”. Well, it depends. If you can formulate a query which gets all of your table1.id1 in one run and table2 has lots of rows so the subselect is expensive, then I’d probably use bulk collect. But keep in mind that depending on the amount of data, you’ll need some PGA to accomplish this.

    But I may point to another – IMHO quite elegant – solution:

    MERGE INTO table2
      USING (select id1 from table1)
       ON (id2 = id2)
      WHEN MATCHED THEN 
       UPDATE SET value=1
    ;
    

    That’s usually faster than doing subqueries and faster than bulk collects: one run on table1 and one run on table2. (Add where clause to your needs)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have lot of products with custom options, now I have requirement to update
I have writen options to a <select> using something like Id.innerHTML = <option value='foo'>Foo</option>;
I have to update an existing site that's based on DDS on top of
I have a table which has event-details. New records will be inserted to this
I have developed a jquery based expand/collapse table with an option of creating new
I have a colour field in the table I am reporting from. I am
I have a list of options on my site that a user can select.
I have created a dropdown menu to select the table, then another dropdown menu
I have a table set out like: <table id=myTable> <thead> <tr> <td><input type=checkbox id=selectall
I'm trying to get values from the table based on the eqid using the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.