标签:cat 结果 tin 地址 mysql视图 执行 而不是 ctc mysql
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 = orders.order_num;
SELECT * FROM productcustomers;
select contact(RTrim(vend_name), ‘(‘, RTrim(vend_country), ‘)‘) as vend_title
from vendors
order by vend_name;
create view vendorlocations as
select contact(RTrim(vend_name), ‘(‘, RTrim(vend_country), ‘)‘) as vend_title
from vendors
order by vend_name;
create view customeremaillist as
select cust_id, cust_name, cust_email
from customers
where cust_email is not null;
select prod_id, quantity, item_price, quantity*item_price as expanded_price
from orderitems
where order_num = 20005;
检索某个特定订单中的物品,计算每种物品的总价格。
为将其转换为一个视图,如下进行:
create view orderitemsexpanded as
select order_num prod_id, quantity, item_price, quantity*item_price as expanded_price
from orderitems;
select * from orderitemsexpanded where order_num = 20005;
??视图是可更新的(即,可以对它们使用INSERT、UPDATE和DELETE)。更新一个视图将更新其基表(可以回忆一下,视图本身没有数据)。如果你对视图增加或删除行,实际上是对其基表增加或删除行。
??但是,并非所有视图都是可更新的。基本上可以说,如果MySQL不能正确地确定被更新的基数据,则不允许更新(包括插入和删除)。这实际上意味着,如果视图定义中有以下操作,则不能进行视图的更新:
标签:cat 结果 tin 地址 mysql视图 执行 而不是 ctc mysql
原文地址:https://www.cnblogs.com/chengmf/p/13170714.html