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