๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ

ํ”„๋กœ๊ทธ๋ž˜๋ฐ ๊ณต๋ถ€/Oracle

[ex16] update, delete

ex16_update, delete

 

update
- ๋ฐ์ดํ„ฐ๋ฅผ ์ˆ˜์ •ํ•˜๋Š” ๋ช…๋ น์–ด
- ์›ํ•˜๋Š” ํ–‰์˜ ์›ํ•˜๋Š” ์ปฌ๋Ÿผ๊ฐ’์„ ์ˆ˜์ •ํ•˜๋Š” ๋ช…๋ น์–ด

~ update ํ…Œ์ด๋ธ”๋ช… set ์ปฌ๋Ÿผ๋ช…=๊ฐ’ [, ์ปฌ๋Ÿผ๋ช…=๊ฐ’] x N [where์ ˆ];

 

delete
- ๋ฐ์ดํ„ฐ๋ฅผ ์‚ญ์ œํ•˜๋Š” ๋ช…๋ น์–ด
- ์›ํ•˜๋Š” ํ–‰์„ ์‚ญ์ œํ•˜๋Š” ๋ช…๋ น์–ด
- where์ ˆ์„ ์ง€์ •ํ•˜์ง€ ์•Š์„ ๊ฒฝ์šฐ ํ…Œ์ด๋ธ”์˜ ๋ชจ๋“  ๋ฐ์ดํ„ฐ๊ฐ€ ์‚ญ์ œ๋œ๋‹ค.โ˜…โ˜…
> ํ…Œ์ด๋ธ”์˜ ๋ชจ๋“  ๋ฐ์ดํ„ฐ๊ฐ€ ์‚ญ์ œ๋˜๋”๋ผ๋„ ๊ตฌ์กฐ๊ฐ€ ์‚ฌ๋ผ์ง€์ง„ ์•Š๊ธฐ ๋•Œ๋ฌธ์— DDL์˜ drop๊ณผ๋Š” ๋‹ค๋ฅด๋‹ค.
~ delete from ํ…Œ์ด๋ธ”๋ช… [where์ ˆ];

โ€ป update, delete ์‹ค์ˆ˜
1. ๋ฐฑ์—…
2. commit/rollback > ํ˜„์žฌ ์„ธ์…˜์— ํ•œํ•ด์„œ ํŠธ๋žœ์žญ์…˜ ๋‹จ์œ„๋กœ
3. ์Šคํฌ๋ฆฝํŠธ

 

/* update */

commit;
rollback;

select * from tblCountry;

-- ๋Œ€ํ•œ๋ฏผ๊ตญ ์ˆ˜๋„: ์„œ์šธ > ์„ธ์ข…
update tblCountry set capital = '์„ธ์ข…'; --๋Œ€ํ•œ๋ฏผ๊ตญ ์„ธ๊ณ„์ •๋ณต.. ํฐ์ผ..
update tblCountry set capital = '์„ธ์ข…' where name = '๋Œ€ํ•œ๋ฏผ๊ตญ';



update tblCountry set
    name = 'ํ•œ๊ตญ', capital = '์ œ์ฃผ', continent = 'EU'
        where name = '๋Œ€ํ•œ๋ฏผ๊ตญ';


-- ๋ชจ๋“  ๋‚˜๋ผ์˜ ์ธ๊ตฌ ์ฆ๊ฐ€!! > ์ผ๊ด„์ ์œผ๋กœ ์ฆ๊ฐ€ > 10% ์ฆ๊ฐ€
update tblCountry set
    population = population * 1.1;

-----------------------------------------------

/*delete*/

commit;
rollback;

select * from tblCountry;

delete from tblCountry where name = '์ผ๋ณธ';

delete from tblCountry where continent = 'EU';

delete from tblCountry;


/* update, delete ์‹ค์ˆ˜ */
--1. ๋ฐฑ์—…
--2. commit/rollback > ํŠธ๋žœ์žญ์…˜ > ํ˜„์žฌ ์„ธ์…˜์— ํ•œํ•ด์„œ..
--3. ์Šคํฌ๋ฆฝํŠธ