使用物化视图进行汇总管理:1、DBA分析昂贵的SQL查询并创建物化视图 2、商业用户查询表和视图 3、oracle服务器使用物化视图重写SQL查询
create materialized view cust_sales_mv (视图名)
pctfree 0 tablespace example (设置储存操作)
storage (initial 1M next 1M pctincrease 0)
build deferred (什么时候建)
refresh complete (如何刷新数据)
enable query rewrite (用来查询重写)
as select c.cust_id,s.channel_id, (详细的查询)
SUM(amount_sold)
from sales s,customers c (详细的表)
where s.cust_id = c.cust_id
group by c.cust_id, s.channel_id(MV的钥匙)
order by c.cust_id, s.channel_id;
时间: 2024-10-12 13:46:17