mysql数据库实验实训6,数据视图(详细) |
您所在的位置:网站首页 › sql数据库实训报告总结范文图片 › mysql数据库实验实训6,数据视图(详细) |
mysql数据库实验实训6,数据视图(详细)
一、实训目的:
1、掌握视图功能和作用 2、掌握视图创建和管理办法 二、实训内容: 对YGGL数据库完成以下视图操作: 1、在员工管理数据库YGGL中创建视图Emp_view1,包含所有男员工的员工编号、姓名、工作年限和学历:代码: mysql> create or replace view Emp_view1 -> as select 员工编号,姓名,工作年限,学历 -> from employees where employees.性别=1 -> with check option; `SELECT * from Emp_view1; 代码: mysql> select * from Emp_view1 -> where 工作年限>=2; 代码: mysql> create or replace view Emp_view2 as -> select Employees.员工编号, Employees.姓名,Departments.部门名称,Salary.收入 -> from Employees,Departments,Salary -> where Employees.员工部门号 = Departments.部门编号 -> and Employees.员工编号 = Salary.员工编号 -> with check option; SELECT * from Emp_view2; 代码: mysql> select 员工编号,姓名,收入 -> from Emp_view2 -> where 部门名称=‘研发部’; 历、出生日期、性别、工作年限和所在部门编号。在创建视图的时候加上 WITH CHECK OPTION 子句。 代码: mysql> create or replace view Emp_view3 -> as -> select 员工编号,姓名,学历,出生日期,性别,工作年限,员工部门号 -> from Employees -> where 工作年限>=2; SELECT * from Emp_view3; 代码: mysql> insert into Emp_view3 -> values -> (041110,“钟晓玲”,“博士”,“1973-12-01”,1,3,4); SELECT * from Emp_view3; 代码: mysql> update Emp_view2 -> set 收入=收入+200.00 -> where 姓名=“李丽”; mysql> SELECT * from Emp_view2; 代码: mysql> delete from Emp_view3 -> where 学历=“本科”; mysql> SELECT * from Emp_view3; 代码: mysql> alter view Emp_view1 -> as -> select Employees.员工编号,Employees.姓名,Salary.收入 -> from Employees,Salary -> where Employees.员工编号=Salary.员工编号; mysql> SELECT * from Emp_view1; 代码: mysql> drop view Emp_view2, Emp_view3; 片转存中…(img-vo2ftppu-1650015123995)] 10、 删除视图 Emp_view2 和 Emp_view3。代码: mysql> drop view Emp_view2, Emp_view3; Query OK, 0 rows affected (0.00 sec) 11、 靓仔靓女点个关注吧,持续更新ing。。。 |
今日新闻 |
点击排行 |
|
推荐新闻 |
图片新闻 |
|
专题文章 |
CopyRight 2018-2019 实验室设备网 版权所有 win10的实时保护怎么永久关闭 |