Study/Oracle
[oracle] 필드 추가 및 수정, SUM, UPDATE
힝쏘
2019. 5. 13. 10:43
* 필드 추가 및 수정은 alter table 이용.....
* ho_info area 필드를 number(19,2) 로 타입을 바꾸고 값을 24로 update
-데이터를 비우고, 필드타입을 수정한다.
update ho_info set area='';
alter table ho_info modify area number(19, 2);
update ho_info set area=24;
* do_info area 필드를 추가하고 각 호의 면적을 sum 해서 update
alter table dong_info add (area number(19, 2));
update dong_info d set area= (
select sum(area) from ho_info h where h.dong_code = d.dong_code group by d.dong_code
);
* apt_info area 필드 추가 하고 dong 의 면적을 sum 해서 update 하시오.
alter table apt_info add (area number(19, 2));
update apt_info a set area = (
select sum(area) from dong_info d where d.apt_code = a.apt_code group by a.apt_code
);