MySql必知必会笔记chapter22-25

本文介绍了MySQL中的高级特性,包括视图的创建与管理,强调了视图在数据检索中的角色而非更新操作。接着讲解了存储过程的概念,如何封装复杂操作以提高效率和安全性。接着探讨了游标的应用,作为在存储过程中处理结果集的工具。最后,阐述了触发器的用法,包括在DELETE、INSERT和UPDATE操作后的自动执行逻辑。
摘要由CSDN通过智能技术生成

22 视图

视图是虚拟的表,只包含使用时动态检索的数据

select cust_name, cust_contact from customers, orders, orderitems
where customers.cust_id=orders.cust_id and orderitems.order_num=order.order_num 
    and prod_id='TNT2';
select cust_name, cust_contact from productcustomers where prod_id='TNT2';--查询封装好的productcustomers视图

每次使用视图时,都必须处理查询,性能会下降。视图必须唯一命名。

create ;show; drop 

create view productcustomers as select cust_name, cust_contact, prod_id
from customers, orders. orderitems where customers.cust_id=orders.cust_id
    and orderitems.order_num=order.order_num;
select cust_nane, cust_contact from productcustomers where prod_id='TNT2';
--重新格式化检索数据
create view vendlocations as select concat(rtrim(vend_name),'('. rtrim(vend_country),
    ')') as vend_title from vendors order by v
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值