写个触发器就可以实现,每次往表2新增数据时,都会触发修改表1的数据,下面是oracle触发器,你可以参照下:
create or replace trigger trigger_test after insert
on 表2 for each row
declare
integrity_error exception;
errno integer;
errmsg char(200);
dummy integer;
found boolean;
begin
if inserting then
update 表1 set Quantity = (select sum(QuantityOfOne) from 表2 where id =:NEW.id);
end if;
exception
when integrity_error then
raise_application_error(errno, errmsg);
end;