直接上例子
1. 查询 购买‘TNT2‘商品的 买家名字,合同
select cust_name,cust_contact FROM customers c inner join orders o on c.cust_id=o.cust_id inner join orderitems oi on oi.order_num=o.order_num and prod_id=‘TNT2‘
2 .创建 视图 productcustomers(没有
prod_id=‘TNT2‘限制条件
)
create view productcustomers as select cust_name,cust_contact,prod_id FROM customers c inner join orders o on c.cust_id=o.cust_id inner join orderitems oi on oi.order_num=o.order_num
3. 查询视图(使用 where prod_id=‘TNT2‘)
4.show create view xxx
5.drop view xxx 删除视图
时间: 2024-11-10 13:57:30