跳转至

视图操作

题目

视图

创建员工信息表的视图,id,name,school,section_title字段的视图

CREATE VIEW staff_info(id,name,school,section_title) AS SELECT staff.staff_id, staff.`name`, staff.school, section.section_title FROM staff INNER JOIN section ON section.section_id = staff.section_id;

修改员工信息表的视图,需要有id,name,school,section_title,position_title字段的视图

ALTER VIEW staff_info AS SELECT staff.staff_id AS id, staff.name AS name,  staff.school AS school,  section.section_title AS section_title, positions.positions_title AS positions_title    FROM staff INNER JOIN section ON section.section_id = staff.section_id INNER JOIN positions ON positions.positions_id = staff.positions_id;

查询员工信息表的id为4的员工姓名,部门名称

SELECT name, section_title FROM staff_info WHERE id = 4;