Good morning
I am trying to do an update via a sql statement on a table containing 47 million rows from a table containing 250 rows.
The structures are as follows
Table 1 - 47 million rows
Offer_id number(5)
Branch number(5)
item vachar2(5)
Date date
sales_value number(9,2)
sales_units number(7)
days number(2)
avg_units number(9,2)
avg_value number(9,2)
I have a primary key on the table of offer_id, branch, item and date.
Table 2 - 250 rows
Offer_id number(5)
days number(2)
I have a primary key on the table of offer_id
I am trying to update Table 1's days with the days from table 2 where the offer_id's match. I have tried using the following sql statement but it is very slow and I am being moaned at from the dba regarding the tablespace used in the undo.
update table_1 a
set days =
(select days from table_2 b
where b.offer_id = a.offer_id)
where exists
(select offer_id from table_2 b
where b.offer_id = a.offer_id);
Any help on how I could speed this up would be greatfully received.
Thanks
I am trying to do an update via a sql statement on a table containing 47 million rows from a table containing 250 rows.
The structures are as follows
Table 1 - 47 million rows
Offer_id number(5)
Branch number(5)
item vachar2(5)
Date date
sales_value number(9,2)
sales_units number(7)
days number(2)
avg_units number(9,2)
avg_value number(9,2)
I have a primary key on the table of offer_id, branch, item and date.
Table 2 - 250 rows
Offer_id number(5)
days number(2)
I have a primary key on the table of offer_id
I am trying to update Table 1's days with the days from table 2 where the offer_id's match. I have tried using the following sql statement but it is very slow and I am being moaned at from the dba regarding the tablespace used in the undo.
update table_1 a
set days =
(select days from table_2 b
where b.offer_id = a.offer_id)
where exists
(select offer_id from table_2 b
where b.offer_id = a.offer_id);
Any help on how I could speed this up would be greatfully received.
Thanks