Oracle SQL update based on subquery between two tables

后端 未结 4 664
無奈伤痛
無奈伤痛 2020-12-31 11:51

I am currently writing update statements to keep a query-able table constantly up to date. The schema is identical between both tables and the contents are not important:

4条回答
  •  自闭症患者
    2020-12-31 12:21

    As you've noticed, you have no selectivity to your update statement so it is updating your entire table. If you want to update specific rows (ie where the IDs match) you probably want to do a coordinated subquery.

    However, since you are using Oracle, it might be easier to create a materialized view for your query table and let Oracle's transaction mechanism handle the details. MVs work exactly like a table for querying semantics, are quite easy to set up, and allow you to specify the refresh interval.

提交回复
热议问题