Notice
Recent Posts
Recent Comments
ยซ   2024/11   ยป
์ผ ์›” ํ™” ์ˆ˜ ๋ชฉ ๊ธˆ ํ† 
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
Archives
Today
In Total
๊ด€๋ฆฌ ๋ฉ”๋‰ด

A Joyful AI Research Journey๐ŸŒณ๐Ÿ˜Š

*[53] 230315 SQL Ch 4. ๋ฐ์ดํ„ฐ์˜ ์ถ”๊ฐ€, ์‚ญ์ œ, ๊ฐฑ์‹ : 16๊ฐ• ํ–‰ ์ถ”๊ฐ€ํ•˜๊ธฐ - INSERT, 17๊ฐ• ์‚ญ์ œํ•˜๊ธฐ - DELETE, 18๊ฐ• ๋ฐ์ดํ„ฐ ๊ฐฑ์‹ ํ•˜๊ธฐ - UPDATE, 19๊ฐ• ๋ฌผ๋ฆฌ์‚ญ์ œ์™€ ๋…ผ๋ฆฌ์‚ญ์ œ [K-๋””์ง€ํ„ธ ํŠธ๋ ˆ์ด๋‹ 53์ผ] ๋ณธ๋ฌธ

๐ŸŒณBootcamp Revision 2023โœจ/Python, Flask, SQL

*[53] 230315 SQL Ch 4. ๋ฐ์ดํ„ฐ์˜ ์ถ”๊ฐ€, ์‚ญ์ œ, ๊ฐฑ์‹ : 16๊ฐ• ํ–‰ ์ถ”๊ฐ€ํ•˜๊ธฐ - INSERT, 17๊ฐ• ์‚ญ์ œํ•˜๊ธฐ - DELETE, 18๊ฐ• ๋ฐ์ดํ„ฐ ๊ฐฑ์‹ ํ•˜๊ธฐ - UPDATE, 19๊ฐ• ๋ฌผ๋ฆฌ์‚ญ์ œ์™€ ๋…ผ๋ฆฌ์‚ญ์ œ [K-๋””์ง€ํ„ธ ํŠธ๋ ˆ์ด๋‹ 53์ผ]

yjyuwisely 2023. 3. 15. 10:45

230315 Wed 53rd class

Ch 4. ๋ฐ์ดํ„ฐ์˜ ์ถ”๊ฐ€, ์‚ญ์ œ, ๊ฐฑ์‹ 
์ง„๋„: p.  152 ~ (๊ต์žฌ: SQL ์ฒซ๊ฑธ์Œ, ์ €์ž: ์•„์‚ฌ์ด ์•„์ธ ์‹œ)
MySQL Workbench Manual: https://dev.mysql.com/doc/workbench/en/
MySQL ํŠœํ† ๋ฆฌ์–ผ: https://www.tutorialspoint.com/mysql/

SQLD ์š”์•ฝ pdf: https://yurimac.tistory.com/40
์ฑ… ์š”์•ฝ (9p) pdf: https://brunch.co.kr/@ydy702/10

 

SQL ์ฒซ๊ฑธ์Œ | ์•„์‚ฌ์ด ์•„์ธ ์‹œ - ๊ต๋ณด๋ฌธ๊ณ 

SQL ์ฒซ๊ฑธ์Œ | ์™•์ดˆ๋ณด๋ฅผ ์œ„ํ•œ ์ •๋ง ์‰ฌ์šด SQL ์ž…๋ฌธ์„œ๋ฅผ ๋งŒ๋‚˜๋ณด์ž!๋ณธ๊ฒฉ์ ์ธ ๋น…๋ฐ์ดํ„ฐ ์‹œ๋Œ€์— ์ ‘์–ด๋“ค๋ฉด์„œ ๊ธฐ์กด ๋Œ€๋น„ ๋” ํšจ์œจ์ ์ด๊ณ  ํญ๋„“์€ ๋ฐ์ดํ„ฐ ๋ถ„์„์„ ์œ„ํ•œ ์ˆ˜์š”๊ฐ€ ์ปค์งˆ ๊ฒƒ์œผ๋กœ ๊ธฐ๋Œ€๋˜๋Š” ๊ฐ€์šด๋ฐ, SQ

product.kyobobook.co.kr

์˜ค๋Š˜ ๋ฐฐ์šด ๊ฒƒ ์ค‘ ๊ธฐ์–ตํ•  ๊ฒƒ์„ ์ •๋ฆฌํ–ˆ๋‹ค.


4์žฅ ๋ฐ์ดํ„ฐ์˜ ์ถ”๊ฐ€, ์‚ญ์ œ, ๊ฐฑ์‹ 

์ฑ…์˜ ๋ชฉ์ฐจ
__16๊ฐ•__ํ–‰ ์ถ”๊ฐ€ํ•˜๊ธฐ - INSERT

1. INSERT๋กœ ํ–‰ ์ถ”๊ฐ€ํ•˜๊ธฐ
2. ๊ฐ’์„ ์ €์žฅํ•  ์—ด ์ง€์ •ํ•˜๊ธฐ
3. NOT NULL ์ œ์•ฝ
4. DEFAULT

__17๊ฐ•__์‚ญ์ œํ•˜๊ธฐ - DELETE
1. DELETE๋กœ ํ–‰ ์‚ญ์ œํ•˜๊ธฐ
2. DELETE ๋ช…๋ น ๊ตฌ

__18๊ฐ•__๋ฐ์ดํ„ฐ ๊ฐฑ์‹ ํ•˜๊ธฐ - UPDATE
1. UPDATE๋กœ ๋ฐ์ดํ„ฐ ๊ฐฑ์‹ ํ•˜๊ธฐ
2. UPDATE๋กœ ๊ฐฑ์‹ ํ•  ๊ฒฝ์šฐ ์ฃผ์˜์‚ฌํ•ญ
3. ๋ณต์ˆ˜์—ด ๊ฐฑ์‹ 
4. NULL๋กœ ๊ฐฑ์‹ ํ•˜๊ธฐ

__19๊ฐ•__๋ฌผ๋ฆฌ์‚ญ์ œ์™€ ๋…ผ๋ฆฌ์‚ญ์ œ
1. ๋‘ ์ข…๋ฅ˜์˜ ์‚ญ์ œ๋ฐฉ๋ฒ•
2. ์‚ญ์ œ๋ฐฉ๋ฒ• ์„ ํƒํ•˜๊ธฐ

16๊ฐ• ํ–‰ ์ถ”๊ฐ€ํ•˜๊ธฐ - INSERT

INSERT ๋ช…๋ น

INSERT INTO ํ…Œ์ด๋ธ”๋ช… VALUES(๊ฐ’1, ๊ฐ’2, ...)

16.1 INSERT๋กœ ํ–‰ ์ถ”๊ฐ€ํ•˜๊ธฐ

์˜ˆ์ œ 4-1) sample41 ํ…Œ์ด๋ธ”

SELECT * FROM sample41;

์˜ˆ์ œ 4-2) sample41 ํ…Œ์ด๋ธ”์˜ ์—ด ๊ตฌ์„ฑ ํ™•์ธํ•˜๊ธฐ

DESC sample41;

์˜ˆ์ œ 4-3) sample41 ํ…Œ์ด๋ธ”์— ํ–‰ ์ถ”๊ฐ€ํ•˜๊ธฐ

INSERT INTO sample41 VALUES(1, 'ABC', '2014-01-25');

์˜ˆ์ œ 4-4) sample41 ํ…Œ์ด๋ธ”

-- INSERT ๊ฒฐ๊ณผ ํ™•์ธํ•˜๊ธฐ
SELECT * FROM sample41;

Point: INSERT ๋ช…๋ น์œผ๋กœ ํ…Œ์ด๋ธ”์— ํ–‰์„ ์ถ”๊ฐ€ํ•  ์ˆ˜ ์žˆ๋‹ค.


16.2 ๊ฐ’์„ ์ €์žฅํ•  ์—ด ์ง€์ •ํ•˜๊ธฐ

INSERT์˜ ์—ด ์ง€์ •

INSERT INTO ํ…Œ์ด๋ธ”๋ช…(์—ด1, ์—ด2, ...) VALUES(๊ฐ’1, ๊ฐ’2, ...)

์˜ˆ์ œ 4-5) ์—ด์„ ์ง€์ •ํ•ด ํ–‰ ์ถ”๊ฐ€ํ•˜๊ธฐ

-- no ์—ด๊ณผ a ์—ด๋งŒ ์ง€์ •ํ•ด ํ–‰ ์ถ”๊ฐ€ํ•˜๊ธฐ
INSERT INTO sample41(a, no) VALUES('XYZ', 2);

SELECT * FROM sample41;

ํ–‰์ด ์ถ”๊ฐ€๋จ


16.3 NOT NULL ์ œ์•ฝ

INSERT INTO sample41(no, a, b) VALUES(NULL, NULL, NULL);

'no' cannot be null. ์—๋Ÿฌ ๋ฉ”์‹œ์ง€๊ฐ€ ๋œฌ๋‹ค.

no ์—ด์— ๋Œ€ํ•ด NULL ๊ฐ’์„ ํ—ˆ์šฉํ•˜์ง€ ์•Š๋Š” NOT NULL ์ œ์•ฝ์ด ๊ฑธ๋ ค์žˆ๊ธฐ ๋•Œ๋ฌธ์ด๋‹ค.
์ œ์•ฝ: ํ…Œ์ด๋ธ”์— ์ €์žฅํ•˜๋Š” ๋ฐ์ดํ„ฐ๋ฅผ ์„ค์ •์œผ๋กœ ์ œํ•œํ•˜๋Š” ๊ฒƒ

Point: NOT NULL ์ œ์•ฝ์ด ๊ฑธ๋ ค์žˆ๋Š” ์—ด์€ NULL ๊ฐ’์„ ํ—ˆ์šฉํ•˜์ง€ ์•Š๋Š”๋‹ค.

์˜ˆ์ œ 4-6) NOT NULL ์ œ์•ฝ ํšŒํ”ผํ•˜๊ธฐ

-- no์—ด์— 3์„ ์ง€์ •ํ•ด ํ–‰ ์ถ”๊ฐ€
INSERT INTO sample41(no, a, b) VALUES(3, NULL, NULL);

SELECT * FROM sample41;


16.4 DEFAULT

์˜ˆ์ œ 4-7) sample411์˜ ์—ด ๊ตฌ์„ฑ ํ™•์ธํ•˜๊ธฐ

DESC sample411;

๋””ํดํŠธ๊ฐ’์€ 0

create table sample411)
	no int not null 1, -- ์—ด๋ช…, ์ž๋ฃŒํ˜•, ์ œ์•ฝ ์กฐ๊ฑด, ๋””ํดํŠธ
	d int 0	-- ์—ด๋ช…, ์ž๋ฃŒํ˜•, (์ œ์•ฝ ์กฐ๊ฑด ์—†์Œ), ๋””ํดํŠธ
)

์˜ˆ์ œ 4-8) sample411์— ํ–‰ ์ถ”๊ฐ€ํ•˜๊ธฐ

-- ๊ฐ’์„ ์ƒ๋žตํ•˜์ง€ ์•Š๊ณ  ํ–‰ ์ถ”๊ฐ€ํ•˜๊ธฐ
INSERT INTO sample411(no, d) VALUES (1,1);

SELECT * FROM sample411;

์˜ˆ์ œ 4-9) ๋ช…์‹œ์ ์œผ๋กœ ๋””ํดํŠธ ์ง€์ •
์ž˜ ์•ˆ ์“ฐ์ด๋Š” ๋ฐฉ๋ฒ•์ด๋‹ค.

-- DEFAULT๋กœ ๊ฐ’์„ ์ง€์ •ํ•ด ํ–‰ ์ถ”๊ฐ€ํ•˜๊ธฐ
INSERT INTO sample411(no, d) VALUES(2, DEFAULT);

SELECT * FROM sample411;

์ž˜ ์“ฐ์ด์ง€ ์•Š๋Š” ๋ฐฉ๋ฒ•์ด๋‹ค.


- ์•”๋ฌต์ ์œผ๋กœ ๋””ํดํŠธ ์ €์žฅ
์˜ˆ์ œ 4-10) ์•”๋ฌต์ ์œผ๋กœ ๋””ํดํŠธ ์ง€์ •

-- ์•”๋ฌต์ ์œผ๋กœ ๋””ํดํŠธ ๊ฐ’์„ ๊ฐ€์ง€๋Š” ํ–‰ ์ถ”๊ฐ€ํ•˜๊ธฐ
INSERT INTO sample411(no) VALUES(3);

SELECT * FROM sample411;

Point: ์—ด์„ ์ง€์ •ํ•˜์ง€ ์•Š์œผ๋ฉด ๋””ํดํŠธ๊ฐ’์œผ๋กœ ํ–‰์ด ์ถ”๊ฐ€๋œ๋‹ค.

์ „์ฒด ๋น„๊ตํ•ด๋ณด๊ธฐ


17๊ฐ• ์‚ญ์ œํ•˜๊ธฐ - DELETE

DELETE ๋ช…๋ น

DELETE FROM ํ…Œ์ด๋ธ”๋ช… WHERE ์กฐ๊ฑด์‹


17.1 DELETE๋กœ ํ–‰ ์‚ญ์ œํ•˜๊ธฐ

DELETE ๋ช…๋ น

DELETE FROM ํ…Œ์ด๋ธ”๋ช… WHERE ์กฐ๊ฑด์‹

์˜ˆ์ œ 4-11) sample41 ํ…Œ์ด๋ธ”

-- sample41 ํ…Œ์ด๋ธ”์— ์ €์žฅ๋œ ๋ฐ์ดํ„ฐ ํ™•์ธ
SELECT * FROM sample41;

Point: DELETE ๋ช…๋ น์œผ๋กœ ํ–‰์„ ์‚ญ์ œํ•  ์ˆ˜ ์žˆ๋‹ค.

์˜ˆ์ œ 4-12) sample41์—์„œ ํ–‰ ์‚ญ์ œํ•˜๊ธฐ

-- sample41 ํ…Œ์ด๋ธ”์—์„œ no ์—ด์ด 3์ธ ํ–‰ ์‚ญ์ œํ•˜๊ธฐ
DELETE FROM sample41 WHERE no = 3;

SELECT * FROM sample41;

Point: DELETE ๋ช…๋ น์€ WHERE ์กฐ๊ฑด์— ์ผ์น˜ํ•˜๋Š” '๋ชจ๋“  ํ–‰'์„ ์‚ญ์ œํ•œ๋‹ค.


17.2 DELETE ๋ช…๋ น ๊ตฌ

์—ญ์ž์ฃผ: MySQL์—์„œ๋Š” DELETE ๋ช…๋ น์—์„œ ORDER BY ๊ตฌ์™€ LIMIT ๊ตฌ๋ฅผ ์‚ฌ์šฉํ•ด ์‚ญ์ œํ•  ํ–‰์„ ์ง€์ •ํ•  ์ˆ˜ ์žˆ๋‹ค.


18๊ฐ• ๋ฐ์ดํ„ฐ ๊ฐฑ์‹ ํ•˜๊ธฐ - UPDATE

UPDATE ๋ช…๋ น

UPDATE ํ…Œ์ด๋ธ”๋ช… SET ์—ด1 = ๊ฐ’1, ์—ด2 = ๊ฐ’2, ... WHERE ์กฐ๊ฑด

18.1 UPDATE๋กœ ๋ฐ์ดํ„ฐ ๊ฐฑ์‹ ํ•˜๊ธฐ

UPDATE ๋ช…๋ น

UPDATE ํ…Œ์ด๋ธ”๋ช… SET ์—ด๋ช… = ๊ฐ’ WHERE ์กฐ๊ฑด์‹

์˜ˆ์ œ 4-13) sample41 ํ…Œ์ด๋ธ”

SELECT * FROM table41;

๋ฌธ๋ฒ•์€ 'SET ์—ด๋ช… = ๊ฐ’'์ด๋‹ค. 
=: ๋Œ€์ž… ์—ฐ์‚ฐ์ž
๊ฐฑ์‹ ํ•ด์•ผ ํ•  ์—ด๊ณผ ๊ฐ’์ด ๋ณต์ˆ˜์ธ ๊ฒฝ์šฐ์—๋Š” '์—ด = ๊ฐ’'์„ ์ฝค๋งˆ(,)๋กœ ๊ตฌ๋ถ„ํ•˜์—ฌ ๋ฆฌ์ŠคํŠธ ํ˜•์‹์œผ๋กœ ์ง€์ •ํ•  ์ˆ˜ ์žˆ๋‹ค.

์˜ˆ์ œ 4-14) sample41์˜ ์…€ ๊ฐ’์„ ๊ฐฑ์‹ ํ•˜๊ธฐ

ํ–‰ ์ง€์ •์€ WHERE no = 2๋กœ ํ•œ๋‹ค. (์กฐ๊ฑด์‹)
๊ฐฑ์‹ ํ•  ๊ฐ’์€ SET b = '2014-09-07'๋กœ ํ•œ๋‹ค. (SET ์—ด๋ช… = ๊ฐ’)

SELECT * FROM sample41;
UPDATE sample41 SET b = '2014-09-07' WHERE no = 2;

SELECT * FROM sample41;

Point: UPDATE ๋ช…๋ น์œผ๋กœ ํ–‰์˜ ์…€ ๊ฐ’์„ ๊ฐฑ์‹ ํ•  ์ˆ˜ ์žˆ๋‹ค.
Point: UPDATE ๋ช…๋ น์—์„œ๋Š” WHERE ์กฐ๊ฑด์— ์ผ์น˜ํ•˜๋Š” '๋ชจ๋“  ํ–‰'์ด ๊ฐฑ์‹ ๋œ๋‹ค.


18.2 UPDATE๋กœ ๊ฐฑ์‹ ํ•  ๊ฒฝ์šฐ ์ฃผ์˜์‚ฌํ•ญ

์˜ˆ์ œ 4-15) UPDATE ๋ช…๋ น์œผ๋กœ ์ฆ๊ฐ€ ์—ฐ์‚ฐํ•˜๊ธฐ

SELECT * FROM sample41;
UPDATE sample41 SET no = no + 1;
SELECT * FROM sample41;


18.3 ๋ณต์ˆ˜์—ด ๊ฐฑ์‹ 

UPDATE ๋ช…๋ น

UPDATE ํ…Œ์ด๋ธ”๋ช… SET ์—ด๋ช…1 = ๊ฐ’1, ์—ด๋ช…2 = ๊ฐ’2, ... WHERE ์กฐ๊ฑด์‹
-- ๋‘ ๊ตฌ๋ฌธ์œผ๋กœ ๋‚˜๋ˆ„์–ด UPDATE ๋ช…๋ น ์‹คํ–‰
UPDATE sample41 SET a = 'xxx' WHERE no = 2;
UPDATE sample41 SET b = '2014-01-01' WHERE no = 2;

-- ํ•˜๋‚˜๋กœ ๋ฌถ์–ด์„œ UPDATE ๋ช…๋ น ์‹คํ–‰
UPDATE sample41 SET a = 'xxx', b = '2014-01-01' WHERE no = 2;

18.4 NULL๋กœ ๊ฐฑ์‹ ํ•˜๊ธฐ

์˜ˆ์ œ 4-20) NULL ์ดˆ๊ธฐํ™”

UPDATE sample41 SET a = NULL;

SELECT * FROM sample41;


19๊ฐ• ๋ฌผ๋ฆฌ์‚ญ์ œ์™€ ๋…ผ๋ฆฌ์‚ญ์ œ p. 174

๋ฌผ๋ฆฌ์‚ญ์ œ: DELETE
๋…ผ๋ฆฌ์‚ญ์ œ: UPDATE (์‚ญ์ œํ•œ ๊ฒƒ์œผ๋กœ ๊ฐ€์ •, ๋ˆˆ์†์ž„)

๋ฌผ๋ฆฌ์‚ญ์ œ์™€ ๋…ผ๋ฆฌ์‚ญ์ œ๋Š” ์ „์šฉ SQL ๋ช…๋ น์ด ๋”ฐ๋กœ ์กด์žฌํ•˜์ง€ ์•Š๋Š”๋‹ค. ์‹œ์Šคํ…œ ์„ค๊ณ„ ๋ถ„์•ผ์— ๊ด€ํ•œ ๊ฒƒ์œผ๋กœ ์‹œ์Šคํ…œ์„ ๊ตฌ์ถ•ํ•  ๋•Œ ์ž์ฃผ ์‚ฌ์šฉํ•˜๋Š” ๋ง์ด๋‹ค.

ํšŒ์›๊ฐ€์ž…                
member                
id password name address gender state   state  
abc 1234 ์ •์ž๋ฐ”     1   1 ํ˜„์žฌ ํšŒ์›
def 5678 ์ด์‹œ์ƒต     1 -> 2   2 ํƒˆํ‡ด(ํšŒ์›์ด ์ง์ ‘)
ghi 9876 ํ™๊ธธ๋™     1 -> 3   3 ํƒˆํ‡ด(๋ธ”๋ž™๋ฆฌ์ŠคํŠธ)

3๋ฒˆ ํšŒ์›์˜ ๊ฒฝ์šฐ ๋งˆ์น˜ ์‚ญ์ œ๊ฐ€ ๋œ ๊ฒƒ์ฒ˜๋Ÿผ ๋งŒ๋“ค์–ด์ค˜์•ผ ํ•œ๋‹ค.

ํƒˆํ‡ด ๋ฒ„ํŠผ์„ ๋ˆŒ๋ €์„ ๋•Œ(ํšŒ์›๊ฐ€์ž… ํ™”๋ฉด)

update member set state = 2 where id = 'def'

๋ธ”๋ž™๋ฆฌ์ŠคํŠธ๋ฒ„ํŠผ(๊ด€๋ฆฌ์ž ํ™”๋ฉด)

update member set state = 3 where id = 'ghi'

-> delete ํ•œ ๊ฑด ์•„๋‹Œ๋ฐ, delete ํ•œ ๊ฒƒ ์ฒ˜๋Ÿผ ๋ณด์—ฌ์ค€๋‹ค.

ํšŒ์›๋ชฉ๋ก๋ฆฌ์ŠคํŠธ

select * from member where state = 1

 


19.1 ๋‘ ์ข…๋ฅ˜์˜ ์‚ญ์ œ๋ฐฉ๋ฒ•

๋ฐ์ดํ„ฐ๋ฅผ ์‚ญ์ œํ•˜๋Š” ๋ฐ์— ๋‘ ๊ฐ€์ง€ ์‚ฌ๊ณ ๋ฐฉ์‹์ด ์žˆ๋‹ค.

๋ฌผ๋ฆฌ ์‚ญ์ œ: SQL์˜ DELETE ๋ช…๋ น์„ ์‚ฌ์šฉํ•ด ์ง์ ‘ ๋ฐ์ดํ„ฐ๋ฅผ ์‚ญ์ œํ•˜์ž๋Š” ์‚ฌ๊ณ  ๋ฐฉ์‹์ด๋‹ค.

๋…ผ๋ฆฌ ์‚ญ์ œ: ํ…Œ์ด๋ธ”์—์„œ ์‹ค์ œ๋กœ ํ–‰์„ ์‚ญ์ œํ•˜๋Š” ๋Œ€์‹ , UPDATE ๋ช…๋ น์„ ์ด์šฉํ•ด '์‚ญ์ œํ”Œ๋ž˜๊ทธ'์˜ ๊ฐ’์„ ์œ ํšจํ•˜๊ฒŒ ๊ฐฑ์‹ ํ•ด๋‘์ž๋Š” ๋ฐœ์ƒ์— ์˜ํ•œ ์‚ญ์ œ๋ฐฉ๋ฒ•์ด๋‹ค. 
- ์žฅ์ : ๋ฐ์ดํ„ฐ๋ฅผ ์‚ญ์ œํ•˜์ง€ ์•Š๊ธฐ ๋•Œ๋ฌธ์— ์‚ญ์ œ๋˜๊ธฐ ์ „์˜ ์ƒํƒœ๋กœ ๊ฐ„๋‹จํžˆ ๋˜๋Œ๋ฆด ์ˆ˜ ์žˆ๋‹ค.
- ๋‹จ์ : ์‚ญ์ œํ•ด๋„ ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค์˜ ์ €์žฅ๊ณต๊ฐ„์ด ๋Š˜์–ด๋‚˜์ง€ ์•Š๋Š”๋‹ค. ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค์˜ ํฌ๊ธฐ๊ฐ€ ์ฆ๊ฐ€ํ•จ์— ๋”ฐ๋ผ ๊ฒ€์ƒ‰์†๋„๊ฐ€ ๋–จ์–ด์ง„๋‹ค. ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜ ์ธก ํ”„๋กœ๊ทธ๋žจ์—์„œ๋Š” ์‚ญ์ œ์ž„์—๋„ ๋ถˆ๊ตฌํ•˜๊ณ  UPDATE ๋ช…๋ น์„ ์‹คํ–‰ํ•˜๋ฏ€๋กœ ํ˜ผ๋ž€์„ ์•ผ๊ธฐํ•œ๋‹ค.


19.2 ์‚ญ์ œ๋ฐฉ๋ฒ• ์„ ํƒํ•˜๊ธฐ

๋ฌผ๋ฆฌ์‚ญ์ œ ์˜ˆ์‹œ
- ์‚ฌ์šฉ์ž๊ฐ€ ํƒˆํ‡ด
- ํ•˜๋“œ์›จ์–ด์˜ ์ œํ•œ: ๋ฐ์ดํ„ฐ๋ฅผ ์ง€์šด๋‹ค.

๋…ผ๋ฆฌ์‚ญ์ œ ์˜ˆ์‹œ
- ์ฃผ๋ฌธ ์ทจ์†Œ

Point: ๋ฌผ๋ฆฌ์‚ญ์ œ์™€ ๋…ผ๋ฆฌ์‚ญ์ œ๋Š” ์šฉ๋„์— ๋งž๊ฒŒ ์„ ํƒํ•œ๋‹ค.


 

728x90
๋ฐ˜์‘ํ˜•

'๐ŸŒณBootcamp Revision 2023โœจ > Python, Flask, SQL' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€

[54] 230316 SQL Ch 5. ์ง‘๊ณ„์™€ ์„œ๋ธŒ์ฟผ๋ฆฌ: 23๊ฐ• ์„œ๋ธŒ์ฟผ๋ฆฌ, 24๊ฐ• ์ƒ๊ด€ ์„œ๋ธŒ์ฟผ๋ฆฌ [K-๋””์ง€ํ„ธ ํŠธ๋ ˆ์ด๋‹ 54์ผ]  (0) 2023.03.16
[53] 230315 SQL Ch 5. ์ง‘๊ณ„์™€ ์„œ๋ธŒ์ฟผ๋ฆฌ: 20๊ฐ• ํ–‰ ๊ฐœ์ˆ˜ ๊ตฌํ•˜๊ธฐ - COUNT, 21๊ฐ• COUNT ์ด์™ธ์˜ ์ง‘๊ณ„ํ•จ์ˆ˜, 22๊ฐ• ๊ทธ๋ฃนํ™” - GROUP BY [K-๋””์ง€ํ„ธ ํŠธ๋ ˆ์ด๋‹ 53์ผ]  (1) 2023.03.15
[52] 230314 SQL Ch 3. ์ •๋ ฌ๊ณผ ์—ฐ์‚ฐ: 9๊ฐ• ์ •๋ ฌ - ORDER BY, 10๊ฐ• ๋ณต์ˆ˜์˜ ์—ด์„ ์ง€์ •ํ•ด ์ •๋ ฌํ•˜๊ธฐ, 11๊ฐ• ๊ฒฐ๊ณผ ํ–‰ ์ œํ•œํ•˜๊ธฐ - LIMIT, 12๊ฐ• ์ˆ˜์น˜ ์—ฐ์‚ฐ, 13๊ฐ• ๋ฌธ์ž์—ด ์—ฐ์‚ฐ, 14๊ฐ• ๋‚ ์งœ ์—ฐ์‚ฐ, 15 CASE ๋ฌธ์œผ๋กœ ๋ฐ์ดํ„ฐ ๋ณ€ํ™˜ํ•˜..  (1) 2023.03.14
[50~55] 230310~230317 SQL ๋ฌธ์ œ ํ’€์–ด๋ณด๊ธฐ (๋ฐ์ดํ„ฐ: Employer, Department) [K-๋””์ง€ํ„ธ ํŠธ๋ ˆ์ด๋‹ 50์ผ~55์ผ]  (1) 2023.03.13
Comments