1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
| create table toto1
(
tid number(1),
tname varchar2(4)
)
insert /*+ APPEND */ into toto1
select 1, 'NOM' from dual
connect by level <= 1e6;
commit;
insert into toto1 values (2, 'NOM2')
commit;
create table toto2
(
tid number(1),
tname varchar2(4)
)
insert into toto2 values (1, 'NOM');
insert into toto2 values (2, 'NOM3');
commit;
update toto1 t1
set t1.tname = (select t2.tname
from toto2 t2
where t2.tid = t1.tid)
where exists (select null
from toto2 t2
where t2.tid = t1.tid);
-- 1000001 lignes maj, 8 sec
rollback;
update toto1 t1
set t1.tname = (select t2.tname
from toto2 t2
where t2.tid = t1.tid
and t2.tname <> t1.tname)
where exists (select null
from toto2 t2
where t2.tid = t1.tid
and t2.tname <> t1.tname);
-- 1 ligne maj, 250 ms |
Partager