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. ์คํฌ๋ฆฝํธ
'ํ๋ก๊ทธ๋๋ฐ ๊ณต๋ถ > Oracle' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[ex18] subquery (0) | 2023.03.21 |
---|---|
[ex17] group by (0) | 2023.03.19 |
[ex14~15] sequence, insert (0) | 2023.03.19 |
[ex13] DDL(Data Definition Language) (0) | 2023.03.19 |
[ex11~12] ๋ ์ง ์๊ฐ ํจ์(date time function), ํ๋ณํ ํจ์(casting function) (0) | 2023.03.19 |