创建视图“view_info”,查询所有员工姓名、员工联系电话、车间地址、车间主任姓名、主任联系方式
代码:create view view_info as select a.name,a.phone,b.address,b.zl_name,b.zl_phone from chengweiqiang_worker a inner join chengweiqiang_workshop b on a.shop_no = b.no;
查看:“view_info”视图字段信息
创建视图“view_ chisel”,查询“Chisel”所在车间的所有员工姓名、员工联系电话、车间地址
代码:create view view_chisel as select a.name,a.phone,b.address from chengweiqiang_worker a inner join chengweiqiang_workshop b on a.shop_no = b.no where shop_no = "ws2";
结 果
查看库中所有表
创建视图“view_standard”,查询生产出质量达标产品的产品编号、员工姓名、员工联系电话
代码:create view view_standard as select a.no,b.name,b.phone from chengweiqiang_product a inner join chengweiqiang_worker b on a.work_no = b.no where IS_QUALIFIED="1";
结果:
查看“view_ standard”视图创建语句
创建视图“view_ product”,查询所有产品的产品编号、是否合格、员工号、员工姓名、员工联系方式、车间编号、车间地址
代码:create view view_product as select a.no,a.IS_QUALIFIED,a.WORK_NO,b.name,b.phone,b.shop_no,c.address from chengweiqiang_product a inner join chengweiqiang_worker b on a.work_no = b.no inner join chengweiqiang_workshop c on b.shop_no = c.no ;
结果:
查看库中所有表
删除“view_ chisel”视图
建视图“view_ leave”,查询存在离职员工的车间编号、车间主任、主任联系方式
代码:create view view_leave as select no,zl_name,zl_phone from chengweiqiang_workshop where no in (select shop_no from chengweiqiang_worker where IS_ONWORK = "0");
结果:
查看库中所有表