[DB]TIL(Today I Learned)_230806

Aspyn Choiยท2023๋…„ 8์›” 6์ผ
0

TIL

๋ชฉ๋ก ๋ณด๊ธฐ
17/37

โ˜๐Ÿป์˜ค๋Š˜ ๋ฐฐ์šด ๊ฒƒ

1. ํ•จ์ˆ˜

- ํ•จ์ˆ˜๋ž€?

  1. ํ•จ์ˆ˜ : ์ปฌ๋Ÿผ์˜ ๊ฐ’์„ ์ฝ์–ด์„œ ์—ฐ์‚ฐํ•œ ๊ฒฐ๊ณผ๋ฅผ ๋ฐ˜ํ™˜

  2. ํ•จ์ˆ˜ ์ข…๋ฅ˜

  • ๋‹จ์ผ ํ–‰ ํ•จ์ˆ˜ : N๊ฐœ์˜ ๊ฐ’์„ ์ฝ์–ด์„œ N๊ฐœ์˜ ๊ฒฐ๊ณผ๋ฅผ ๋ฐ˜ํ™˜
  • ๊ทธ๋ฃน ํ•จ์ˆ˜ : N๊ฐœ์˜ ๊ฐ’์„ ์ฝ์–ด์„œ 1๊ฐœ์˜ ๊ฒฐ๊ณผ๋ฅผ ๋ฐ˜ํ™˜ (ํ•ฉ๊ณ„, ํ‰๊ท , ์ตœ์†Œ, ์ตœ๋Œ€)

2. ๋‹จ์ผ ํ–‰ ํ•จ์ˆ˜

- LENGTH

- INSTR

- SUBSTR

- TRIM

- ABS

- MOD

- ROUND

- CEIL / FLOOR / TRUNC

- SYSDATE / SYSTIMESTAMP / MONTH_BETWEEN

- ADD_MONTHS / LAST_DAY

- EXTRACT

- TO_CHAR


- TO_DATE

- TO_NUMBER

- NVL

- DECODE

- CASE WHEN

3. ๊ทธ๋ฃน ํ•จ์ˆ˜

- SUM / AVG

- MIN / MAX

- COUNT

4. GROUP BY, HAVING์ ˆ

- GROUP BY์ ˆ


- WHERE์ ˆ

- GROUP BY ๊ทธ๋ฃน ๋‚ด ๊ทธ๋ฃน

- HAVING์ ˆ

- ์ง‘๊ณ„ํ•จ์ˆ˜(ROLLUP, CUBE)

- SET OPERATOR(์ง‘ํ•ฉ ์—ฐ์‚ฐ์ž)

  1. ์ง‘ํ•ฉ์—ฐ์‚ฐ์ž๋ž€? : ์—ฌ๋Ÿฌ SELECT์˜ ๊ฒฐ๊ณผ๋ฅผ ํ•˜๋‚˜์˜ ๊ฒฐ๊ณผ๋กœ ๋งŒ๋“œ๋Š” ์—ฐ์‚ฐ์ž
  2. ์ข…๋ฅ˜
  • UNION(ํ•ฉ์ง‘ํ•ฉ) : ๋‘ SELECT ๊ฒฐ๊ณผ๋ฅผ ํ•˜๋‚˜๋กœ ํ•ฉ์นจ. ๋‹จ, ์ค‘๋ณต์€ ํ•œ๋ฒˆ๋งŒ ์ž‘์„ฑ
  • INTERSECT(๊ต์ง‘ํ•ฉ) : ๋‘ SELCET ๊ฒฐ๊ณผ ์ค‘ ์ค‘๋ณต๋˜๋Š” ๋ถ€๋ถ„๋งŒ ์กฐํšŒ
  • UNION ALL : UNION + INTERSECT ํ•ฉ์ง‘ํ•ฉ์—์„œ ์ค‘๋ณต ๋ถ€๋ถ„ ์ œ๊ฑฐ X
  • MINUS(์ฐจ์ง‘ํ•ฉ) : A์—์„œ A,B ๊ต์ง‘ํ•ฉ ๋ถ€๋ถ„์„ ์ œ๊ฑฐํ•˜๊ณ  ์กฐํšŒ

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