View
๋ฐ์ํ
๐ก VEIW ์์ฑ
- ๋จ์ผ ํ ์ด๋ธ , ๋ค์ค ํ ์ด๋ธ: ์กฐ์ธ, ์๋ธ์ฟผ๋ฆฌ, ์์ฃผ ์ฌ์ฉ๋๋ Read Only ๋ฑ → ๋น์ฉ ์ ๊ฐ์ ์ํจ
#viwe ์์ฑ: create view [Or replace ] view ์ด๋ฆ as select query;
create view v_employee
as
select e.employee_id as '์ฌ์๋ฒํธ', e.first_name as '์ฌ์๋ช
', d.department_name '๋ถ์๋ช
'
from employees e, departments d
where e.department_id = d.department_id;
#๋์ค์ rollback์ ์ํด ์ธํ
set autocommit=false;
#๋ทฐ ์์ฑ ํ ํ์ธ
select * from v_employee;
#์ฐธ์กฐ ํ
์ด๋ธ ๋ณ๊ฒฝ1
select department_id
from employees
where employee_id=202;
update employees
set department_id=10
where employee_id=202;
#๋ทฐ ํ์ธ
select * from v_employee;
#์ฐธ์กฐ ํ
์ด๋ธ ๋ณ๊ฒฝ2
update employees
set department_id=10
where employee_id=202;
update departments
set department_name ='๊ด๋ฆฌ๋ถ'
where department_id=10;
๊ธฐ์กด์ ํ ์ด๋ธ(์ฐธ์กฐ๋ ํ ์ด๋ธ)์๋ ๋ฌผ๋ฆฌ์ ์ธ ๋ณ๊ฒฝ์ด ์์ ์์๋ ๋ทฐ์๋ ๋ฐ์์ด ๋๋๊ฐ?
ใ ใ , ๋ฐ์์ด ๋๋ค
๐ก VEIW ์ญ์
#๋ทฐ ์ญ์ DROP view ์ด๋ฆ
DROP view v_employee;
๋ทฐ ์ญ์ ์ ์ฐธ์กฐ๋ ํ ์ด๋ธ์ ์ํฅ์ ์ฃผ์ง ์๋๋ค
๋ฐ์ํ
'CS > DB' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[DB] JDBC ํ ์คํธ (0) | 2022.09.14 |
---|---|
[MySQL] Mac์์ ์ดํด๋ฆฝ์ค MySQL ์ฐ๋ํ๊ธฐ (MySQL Connector Java) (0) | 2022.09.14 |
[DB] ๋งฅM1_MySQL ๋ค์ด Workbench (0) | 2022.09.12 |
[DB] ๋ฝ(Lock)์ด๋? (0) | 2022.09.08 |
[DB] ๐ก๋ ๋์ค(Redis)๋? (0) | 2022.09.08 |
reply