Answer the question
In order to leave comments, you need to log in
Is it possible to update the data in the table in parts?
Greetings!
Please tell me. you need to update the fields ("comments", "receipt", "date") in the table (test_p ) from the table (ORG_P ) in parts (approximately 100,000 unique records) because there are more than 3 million records in the table (ORG_P ).
Ie
the 1st time we update 100k records,
the 2nd time we update other 100k not included in the 1st time
There is an example, but it updates all records by max("record_id") .
declare
v_count_rows number := 2; --кол-во обновляемых записей
v_maxid number;
v_id number := 0; - начальное значение
begin
select max("record_id") into v_maxid from test_p;
while v_id < v_maxid loop
update test_p t1
set ("comments", "receipt", "date") =
(select t2."comments", t2."receipt", t2."period_date"
from org_p t2
where "record_id" between v_id and
least(v_maxid, v_id + v_count_rows)
and t1."record_id" = t2."record_id")
--пров-ка на существование
where exists (select 1
from ORG_P t2
where "record_id" between v_id and
least(v_maxid, v_id + v_count_rows)
and t1."record_id" = t2."record_id");
v_id := v_id + v_count_rows;
end loop;
commit;
end;
Answer the question
In order to leave comments, you need to log in
There is something strange about your request. I would suggest rewriting it to merge and getting rid of the PL/SQL block altogether.
Maybe OFFSET? Example from www.dba-oracle.com/t_offset_fet_first_rows_only.htm:
select
ename
from
emp
order by ename
offset 5 rows
fetch next 5 rows only;
Oracle usually uses the rownum pseudo-column.
www.gokhanatil.com/2008/10/how-to-limit-the-number...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question