Oracle #2 - DML (CRUD)

ennakoidaยท2023๋…„ 6์›” 13์ผ
0

Oracle

๋ชฉ๋ก ๋ณด๊ธฐ
2/13

๐Ÿ“CRUD

Create(์ƒ์„ฑ - Insert), Read(์ฝ๊ธฐ - Select), Update(๊ฐฑ์‹ ), Delete(์‚ญ์ œ)

CREATE : INSERT

INSERT INTO STUDENT_TBL VALUES('์‚ฌ์šฉ์ž', 44, 4, '๊ฒฝ๊ธฐ๋„ ๋ถ€์ฒœ์‹œ');

INSERT์˜ VALUES ์— ์›ํ•˜๋Š” ๋ฐ์ดํ„ฐ๋ฅผ ๋„ฃ์„ ๋•Œ์—๋Š” ๊ฐ ์ž๋ฃŒํ˜•์„ ๋งž์ถฐ์„œ ์ ์–ด์•ผ ํ•œ๋‹ค.


READ : SELECT

SELECT * FROM STUDENT_TBL;

* ๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด ALL ์„ ํ‘œํ˜„ํ•  ์ˆ˜ ์žˆ๋‹ค.


UPDATE

-- ์ถ”๊ฐ€๋œ ๋ฐ์ดํ„ฐ ์ˆ˜์ •
-- UPDATE ํ…Œ์ด๋ธ”๋ช… SET (์ˆ˜์ •ํ•˜๊ณ  ์‹ถ์€ ํ…Œ์ด๋ธ” ์นผ๋Ÿผ๋ช… = ๊ฐ’) WHERE (์ˆ˜์ •ํ•˜๊ณ  ์‹ถ์€ ๋ฐ์ดํ„ฐ ํŠน์ •)
-- ์‚ฌ์šฉ์ž์˜ AGE 44 > 56

UPDATE STUDENT_TBL SET STUDENT_AGE = 56 WHERE STUDENT_NAME = '์‚ฌ์šฉ์ž';

-- UPDATE STUDENT_TBL SET STUDENT_AGE = 56; 
-- where ์ ˆ ์—†์œผ๋ฉด ๋ชจ๋“  ํ–‰์˜ ๊ฐ’์„ ๋ณ€๊ฒฝํ•œ๋‹ค

DELETE

-- ์‚ญ์ œ

DELETE FROM STUDENT_TBL WHERE STUDENT_NAME = '์ผ์šฉ์ž';

-- DELETE FROM STUDENT_TBL; 
-- where ์ ˆ์ด ์—†์œผ๋ฉด ์ „์ฒด๋ฅผ ๋‹ค ๋‚ ๋ ค๋ฒ„๋ฆผ!

0๊ฐœ์˜ ๋Œ“๊ธ€