目录
1.创建视图“view_info”,查询所有员工姓名、员工联系电话、车间地址、车间主任姓名、主任联系方式
3.创建视图“view_ chisel”,查询“Chisel”所在车间的所有员工姓名、员工联系电话、车间地址
5.创建视图“view_ standard”,查询生产出质量达标产品的产品编号、员工姓名、员工联系电话
7.创建视图“view_ product”,查询所有产品的产品编号、是否合格、员工号、员工姓名、员工联系方式、车间编号、车间地址
10.创建视图“view_ leave”,查询存在离职员工的车间编号、车间主任、主任联系方式
1.创建视图“view_info”,查询所有员工姓名、员工联系电话、车间地址、车间主任姓名、主任联系方式
create view view_info as select wk.name,wk.phone,ws.address,ws.name wsn,ws.phone wsp from
-> zhongjinlin_worker wk right join zhongjinlin_workshop ws on
-> wk.shop_no = ws.no;
编辑
编辑
2.查看“view_info”视图字段信息
desc view_info;
编辑
3.创建视图“view_ chisel”,查询“Chisel”所在车间的所有员工姓名、员工联系电话、车间地址
create view view_chisel as select wk.name,wk.phone,ws.address from
-> zhongjinlin_worker wk inner join zhongjinlin_workshop ws
-> on wk.shop_no = ws.no where shop_no = "WS1";
编辑
编辑
4.查看库中所有表
show tables;
编辑
5.创建视图“view_ standard”,查询生产出质量达标产品的产品编号、员工姓名、员工联系电话
create view view_standard as select no,name,phone from zhongjinlin_worker where
-> is_onwork="1";
编辑
编辑
6.查看“view_ standard”视图创建语句
show create view view_standard\G;
编辑
7.创建视图“view_ product”,查询所有产品的产品编号、是否合格、员工号、员工姓名、员工联系方式、车间编号、车间地址
create view view_product as
-> select a.no ab,a.is_qualified,b.no abc,b.name,b.phone,c.no,c.address
-> from zhongjinling_product a inner join zhongjinlin_worker b
-> on a.workno = b.no
-> inner join zhongjinlin_workshop c
-> on b.shop_no = c.no;
编辑
编辑
8.查看库中所有表
show tables;
编辑
9.删除“view_ chisel”视图
drop view view_chisel;
编辑
10.创建视图“view_ leave”,查询存在离职员工的车间编号、车间主任、主任联系方式
create view view_leave as
-> select no,name,phone from zhongjinlin_workshop where no
-> in (select shop_no from zhongjinlin_worker where is_onwork = "0");
编辑
编辑
11.查看库中所有表
show tables;
编辑