본문 바로가기

Study/Oracle

[oracle] 필드 추가 및 수정, SUM, UPDATE

* 필드 추가  수정은 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

);

'Study > Oracle' 카테고리의 다른 글

[oracle] create, alter, update  (0) 2019.05.13
[oracle] update  (0) 2019.05.13
[oracle] 여러가지 데이터 삽입 방법  (0) 2019.05.13
[oracle] 대용량 데이터 삽입  (0) 2019.05.13
[oracle] create  (0) 2019.05.13