Search

๋ทฐ

๋ทฐ (VIEW)

"๊ฐ€์ƒ ํ…Œ์ด๋ธ”โ€
ํ•˜๋‚˜ ์ด์ƒ์˜ ํ…Œ์ด๋ธ”์„ ์กฐํšŒํ•˜๋Š” SELECT ๋ฌธ์„ ์ €์žฅํ•œ ๊ฐ์ฒด
๋ฌผ๋ฆฌ์ ์œผ๋กœ ์ €์žฅ๋˜๋Š” ํ…Œ์ด๋ธ”์ด ์•„๋‹ˆ๋ผ, ๋…ผ๋ฆฌ์ ์œผ๋กœ๋งŒ ๊ธฐ์กด์˜ ํ…Œ์ด๋ธ”๋“ค์˜ ์กฐํšŒ๊ฒฐ๊ณผ๋ฅผ ์ •์˜๋œ๋‹ค.

๋ชฉ์ 

1.
ํŽธ๋ฆฌ์„ฑ : ์ฟผ๋ฆฌ์˜ ๋ณต์žก๋„๋ฅผ ์ค„์ด๊ธฐ ์œ„ํ•ด์„œ
2.
๋ณด์•ˆ์„ฑ : ๋ฏผ๊ฐํ•œ ์ •๋ณด์— ๋Œ€ํ•œ ๋…ธ์ถœ์„ ๋ฐฉ์ง€ํ•˜๊ธฐ ์œ„ํ•ด์„œ(์ฃผ๋ฏผ๋ฒˆํ˜ธ, ๋น„๋ฐ€๋ฒˆํ˜ธ)

๋ทฐ ์ƒ์„ฑ

CREATE [OR REPLACE] VIEW ๋ทฐ์ด๋ฆ„ (์ปฌ๋Ÿผ1, ์ปฌ๋Ÿผ2, ์ปฌ๋Ÿผ3, ... ) AS ( SELECT ๋ฌธ );
SQL
๋ณต์‚ฌ

๋ทฐ ์‚ญ์ œ

DROP VIEW ๋ทฐ์ด๋ฆ„;
SQL
๋ณต์‚ฌ

์˜ˆ์‹œ ์ฝ”๋“œ

โ€ข
์‚ฌ์›๋ฒˆํ˜ธ, ์ง์›๋ช…, ๋ถ€์„œ๋ฒˆํ˜ธ, ๋ถ€์„œ๋ช…, ์ด๋ฉ”์ผ, ์ „ํ™”๋ฒˆํ˜ธ, ์ฃผ๋ฏผ๋ฒˆํ˜ธ, ์ž…์‚ฌ์ผ์ž, ๊ธ‰์—ฌ, ์—ฐ๋ด‰์„ ์กฐํšŒํ•˜๋Š” ๋ทฐ๋ฅผ ์ƒ์„ฑํ•˜์‹œ์˜ค.
CREATE OR REPLACE VIEW VE_EMP_DEPT AS SELECT e.emp_id ,e.emp_name ,d.dept_id ,d.dept_title ,e.email ,e.phone -- ์ฃผ๋ฏผ๋“ฑ๋ก๋ฒˆํ˜ธ ,RPAD( SUBSTR(emp_no, 1, 8), 14, '*' ) emp_no -- ์ž…์‚ฌ์ผ์ž ,TO_CHAR( hire_date, 'YYYY.MM.DD' ) hire_date -- ๊ธ‰์—ฌ ,TO_CHAR( salary, '999,999,999' ) salary -- ์—ฐ๋ด‰ ,TO_CHAR( (salary + NVL( salary*bonus, 0)) * 12, '999,999,999,999') yr_salary FROM employee e LEFT JOIN department d ON (e.dept_code = d.dept_id) ;
SQL
๋ณต์‚ฌ
โ€ข
๋ทฐ ์กฐํšŒ
SELECT * FROM VE_EMP_DEPT;
SQL
๋ณต์‚ฌ