问题描述
创建View MyView为
更新客户设置Customers.MTDSale = 0,Customers.YTDSale = 0,Customers.LastMonthSale = 0,Customers.LastYearSale = 0,Customers.LastYearThisMonthSale = 0,Customers.LastYearLastMonthSale = 0,Customers.ChannelID = 0;
Create View MyView As
UPDATE Customers SET Customers.MTDSale = 0, Customers.YTDSale = 0, Customers.LastMonthSale = 0, Customers.LastYearSale = 0, Customers.LastYearThisMonthSale = 0, Customers.LastYearLastMonthSale = 0, Customers.ChannelID = 0;
推荐答案
Create View MyView As
SELECT * Customers WHERE Age > 18
/*Can update*/
Create View MyView As
SELECT * Customers, CustomerAddress WHERE Age > 18
and
customer.Id = CustomerAddress.Id
/*Cannot update*/
此外,您只能执行在视图中指定足够的列以满足任何非null约束的插入操作.
作为附带说明,您似乎正在尝试设置问题的默认值,这真的是您想要的吗?
[正确的代码格式]
Additionally, you can only perform an insert where enough columns in the view are specified to satisfy any not null constraints.
As a side note, it looks like you are trying to set default values in your question, is this really what you want instead?
[Corrected code formatting]
这篇关于如何在View中编写更新,插入,删除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!