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

๐Ÿ“š ์ „๊ณต ๊ณต๋ถ€/DB๊ธฐ์ดˆ

(14)
[SQL] mysql ๋ฌธ์ž์—ด ํ•จ์ˆ˜ ์ด์šฉ ์—ฐ์Šต๋ฌธ์ œ, ์˜ˆ์ œ ๋ฒˆ์—ญ๊ธฐ ๋Œ๋ฆฐ๊ฑฐ๋ผ ์–ด์ƒ‰ํ•œ ๋ฌธ์žฅ์ด ์กด์žฌํ•ฉ๋‹ˆ๋‹ค! ๊ทธ๋ž˜๋„ ์ดํ•ดํ• ๋งŒํ•จ.. ์—ฐ์Šต์šฉ์œผ๋กœ ๋Œ€์ถฉ ๋ณด๋ ค๊ณ  ์จ๋†“๋Š”๊ฑฐ๋ผ ๋ฌธ์ฒด ์ด์ƒํ•ด๋„ ๋ฌด์‹œํ•จ chatGPT๊ฐ€ ์ œ์•ˆํ•ด์ค€ mysql ๋ฌธ์ž์—ด ํ•จ์ˆ˜ ์ด์šฉ ๋ฌธ์ œ์™€ ์˜ˆ์‹œ ๋‹ต์•ˆ์ž…๋‹ˆ๋‹ค~ ๋ฌธ์ œ1 : users๋ผ๊ณ  ํ•˜๋Š” ํ…Œ์ด๋ธ”์ด ์žˆ๋Š”๋ฐ ์ปฌ๋Ÿผ์ด ํฌํ•จ๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค.full_name๊ฐ ์‚ฌ์šฉ์ž์˜ ์ด๋ฆ„๊ณผ ์„ฑ์„ ์ถ”์ถœํ•˜์—ฌ ๋‹ค๋ฅธ ์—ด์— ํ‘œ์‹œํ•ฉ๋‹ˆ๋‹ค. ์ด ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•˜๋ ค๋ฉดSUBSTRING_INDEX()์—์„œ ์„ฑ๊ณผ ์ด๋ฆ„์„ ์ถ”์ถœํ•˜๋Š” ํ•จ์ˆ˜full_name๊ธฐ๋‘ฅ. ๋‹ค์Œ์€ ์ด ์ž‘์—…์„ ์ˆ˜ํ–‰ํ•˜๋Š” ์ฟผ๋ฆฌ์ž…๋‹ˆ๋‹ค. SELECT full_name, SUBSTRING_INDEX(full_name, ' ', 1) AS first_name, SUBSTRING_INDEX(full_name, ' ', -1) AS last_name FROM user..
[SQL] mysql ๋ฌธ์ž์—ด์„ ๋‹ค๋ฃจ๋Š” ํ•จ์ˆ˜ ์ถ”๊ฐ€ ์ •๋ฆฌ ์„œ๋ธŒ์ŠคํŠธ๋ง ํ•จ์ˆ˜ LEFT(): ๋ฌธ์ž์—ด์—์„œ ๋งจ ์™ผ์ชฝ ๋ฌธ์ž๋ฅผ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค. SELECT LEFT('Hello World', 5); -- Output: Hello RIGHT(): ๋ฌธ์ž์—ด์—์„œ ๊ฐ€์žฅ ์˜ค๋ฅธ์ชฝ ๋ฌธ์ž๋ฅผ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค. SELECT RIGHT('Hello World', 5); -- Output: World SUBSTRING(): ์ง€์ •ํ•œ ์œ„์น˜์—์„œ ์‹œ์ž‘ํ•˜๋Š” ๋ฌธ์ž์—ด์—์„œ ํ•˜์œ„ ๋ฌธ์ž์—ด์„ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค. SELECT SUBSTRING('Hello World', 7); -- Output: World SUBSTRING_INDEX(): ์ง€์ •ํ•œ ์œ„์น˜์—์„œ ์‹œ์ž‘ํ•˜์—ฌ ์ง€์ •๋œ ๊ตฌ๋ถ„ ๊ธฐํ˜ธ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๋ฌธ์ž์—ด์—์„œ ํ•˜์œ„ ๋ฌธ์ž์—ด์„ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค. SELECT SUBSTRING_INDEX('www.example.com', '.', 2); -- Outp..
[SQL] mysql ๋‚ด์žฅํ•จ์ˆ˜ ์ •๋ฆฌ ๋ฌธ์ž์—ด ํ•จ์ˆ˜ CONCAT(): 2๊ฐœ ์ด์ƒ์˜ ๋ฌธ์ž์—ด์„ ์—ฐ๊ฒฐํ•ฉ๋‹ˆ๋‹ค. SELECT CONCAT('Hello', 'World'); -- Output: HelloWorld SUBSTR(): ๋ฌธ์ž์—ด์—์„œ ํ•˜์œ„ ๋ฌธ์ž์—ด์„ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค. SELECT SUBSTR('Hello World', 7); -- Output: World UPPER(): ๋ฌธ์ž์—ด์„ ๋Œ€๋ฌธ์ž๋กœ ๋ณ€ํ™˜ํ•ฉ๋‹ˆ๋‹ค. SELECT UPPER('Hello World'); -- Output: HELLO WORLD LOWER(): ๋ฌธ์ž์—ด์„ ์†Œ๋ฌธ์ž๋กœ ๋ณ€ํ™˜ํ•ฉ๋‹ˆ๋‹ค. SELECT LOWER('Hello World'); -- Output: hello world LENGTH(): ๋ฌธ์ž์—ด ๊ธธ์ด๋ฅผ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค. SELECT LENGTH('Hello World'); -- Output: 11 ์ˆซ..
[SQLD] ์ „๊ณต์ž sqld ์‹œํ—˜ ํ›„๊ธฐ/ ์ค€๋น„๋ฐฉ๋ฒ•/ ๊ณต๋ถ€ https://www.dataq.or.kr/www/main.do โฌ†โฌ† ๋ฐ์ดํ„ฐ์ž๊ฒฉ๊ฒ€์ • ํ™ˆํŽ˜์ด์ง€ โฌ†โฌ† SQLD๋Š” SQL "๊ฐœ๋ฐœ์ž" ์ž๊ฒฉ์ฆ ์‹œํ—˜์˜ ์•ฝ์ž์ž…๋‹ˆ๋‹ค!! ์ „๋ฌธ๊ฐ€ ์‹œํ—˜(SQLP)์€ ์‹ค๊ธฐ๋„ ์žˆ๊ณ  ๋” ์–ด๋ ค์šด ๋ฐ˜๋ฉด์—, ๊ฐœ๋ฐœ์ž ์‹œํ—˜์€ ํ•„๊ธฐ๋งŒ ์น˜๋ฉด ๋˜๊ณ  ์ƒ๋Œ€์ ์œผ๋กœ ์‰ฌ์›Œ์„œ ๋Œ€ํ•™์ƒ๋“ค๋„ ๋งŽ์ด ์‘์‹œํ•˜๋”๋ผ๊ณ ์š”. ์ €๋Š” ํ•™๊ต์—์„œ "๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ๊ธฐ์ดˆ" ๊ณผ๋ชฉ์„ ์ˆ˜๊ฐ•ํ•˜๋ฉด์„œ, ์„ ๋ฐฐ์—๊ฒŒ SQLD ์‹œํ—˜์„ ๊ฐ™์ด ์น˜๋ฉด ์ข‹๋‹ค๋Š” ๋ง์„ ๋“ฃ๊ณ  ์‹œํ—˜์„ ์ค€๋น„ํ•˜๊ธฐ ์‹œ์ž‘ํ–ˆ์Šต๋‹ˆ๋‹ค! ์‚ฌ์‹ค ์ง„์งœ ์‹œํ—˜์ค€๋น„๋Š” 4์ผ๋™์•ˆ๋งŒ ํ•˜๊ธด ํ–ˆ๋Š”๋ฐ,...(์ „๊ณต์ž๋ผ์„œ) ์šฐ์„  DB ๊ณผ๋ชฉ์—์„œ ๊ธฐ๋ณธ์ ์ธ SQL๋ฌธ์— ๋Œ€ํ•ด์„œ๋Š” ๋‹ค ๋ฐฐ์šด ์ƒํƒœ์˜€๊ณ ์š”, ์–ผ๋งˆ์ „์— ์ค‘๊ฐ„๊ณ ์‚ฌ๋ฅผ ๋ณธ๋‹ค๊ณ  ๊ณต๋ถ€๋„ ์—ด์‹ฌํžˆ ํ•ด ๋†“์€ ์ƒํƒœ๋ผ์„œ ์ž˜์น  ์ˆ˜ ์žˆ์—ˆ๋˜ ๊ฒƒ ๊ฐ™๊ธฐ๋„ ํ•ฉ๋‹ˆ๋‹ค ์šฐ์„ , SQL ์‹œํ—˜์„ ์น˜์‹ค ์ƒ๊ฐ์ด๋ผ๋ฉด ์•„๋ž˜ ์นดํŽ˜์— ..
[DB] ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ๋ณด์•ˆ Database Security and Authorization Subsystem ๋ณด์•ˆ ๋ฐ ๊ถŒํ•œ๋ถ€์—ฌ DB security legal and ethical policy issues system-related issues security levels Threats to Databases Loss of integrity : ๋ฌด๊ฒฐ์„ฑ ์ƒ์‹ค Loss of availability : ๊ฐ€์šฉ์„ฑ ์ƒ์‹ค Loss of confidentiality : ๊ธฐ๋ฐ€์„ฑ ์ƒ์‹ค access control, inference control, flow control, encryption DB security : not an isolated concern multiuser DB system database security and authoriza..
[DB] ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ๋ณต๊ตฌ Recovery Techniques Recovery Concept recent consistent state : no errors in db, no inconsistencies in db systme log Catastrophic failure (์น˜๋ช…์  ์žฅ์• ) → backed up, redoing Noncatastrophic failure (๋น„์žฌํ•ด์  ์žฅ์• ) → undoing, redo, deferred update&immediate update Caching(Buffering) of disk blocks ํšจ์œจ์„ฑ์„ ์œ„ํ•ด์„œ ์บ์‹œ ์‚ฌ์šฉ DBMS cache Buffer replacement : ๋ฒ„ํผ ๊ต์ฒด( flush ) dirty bit : ๋ฒ„ํผ๊ฐ€ ์ˆ˜์ •๋˜์—ˆ๋Š”์ง€ ์—ฌ..
[DB] ๋™์‹œ์„ฑ ์ œ์–ด Concurrency Control Techniques Concurrency Control Protocols : guarantee serializability (์ง๋ ฌํ™” ๋ณด์žฅ) Locking Timestamps multiversion CC protocols Optimistic protocols Multiple granularity concurrency control protocol Two-phase Locking Techniques : ์ด์ค‘ ๋ผํ‚น lock ์ƒํƒœ 1, unlock ์ƒํƒœ๋Š” 0 Lock table : lock ์ •๋ณด๋ฅผ ๊ด€๋ฆฌํ•˜๋Š” ์„œ๋ธŒ์‹œ์Šคํ…œ plus a queue for transactions that are waiting to access item Shared/Exclusive (or Read/Wr..
[DB] Transaction processing Transaction Concepts Concurrent Executions Transaction Schedule Serializability Recoverability Single-User vs Multiuser Systems ๊ต๋Œ€ ์ˆ˜ํ–‰ : interleaved concurrency Transaction : an executing program that forms a logical unit of db processing Begin transaction - end transaction; includes DB access operations read-only / read-write transaction read-item(X) : ๋””์Šคํฌ๋ธ”๋ก ์ฃผ์†Œ์ฐพ๊ธฐ-๋ฒ„ํผ์— ๋ณต์‚ฌ-ํ”„๋กœ๊ทธ๋žจ ๋ณ€์ˆ˜๋กœ ๋ณต์‚ฌ write-item(X)..

728x90