赞
踩
创建视图图的基本语法:
CREATE VIEW <视图名称>(<列名1>,<列名2>,...) AS
<SELECT语句>
from 表名
group by 列名;-- 该语句可以选择或者不写该语句,两者的区别就是是否有汇总
drop view profit;
create view profit (种类,售价, 进价,利润)
As
select product_type,sale_price,purchase_price,sale_price - purchase_price as profit
from product
group by product_type;
select * from profit;
结果如下:
drop view profit1;
create view profit1 (种类,售价, 进价,利润)
As
select product_type,sale_price,purchase_price,sale_price - purchase_price as profit
from product;
select * from profit1;
结果如下:
修改视图结构的基本语法如下:
ALTER VIEW <视图名> AS <SELECT语句>
-- 例如:
ALTER VIEW profit
AS
SELECT product_type, sale_price
FROM Product
WHERE regist_date > '2009-09-11';
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。