코드 3-7에는 비슷한 유형의 오라클에서 제공하는 구체화된 뷰(Materialized View)가 있다.
코드 3-7 오라클에서 테이블 여섯 개를 참조하는 구체화된 뷰 생성
CREATE MATERIALIZED VIEW SalesSummary
TABLESPACE TABLESPACE1
BUILD IMMEDIATE
REFRESH FAST ON DEMAND
AS
SELECT SUM(t1.Sales) AS Sales,
SUM(t1.Cost * t1.Quantity) AS Cost,
SUM(t1.Quantity) AS Quantity,
SUM(t1.GrossProfit) AS GrossProfit,
t5.RegionName AS RegionName,
t5.CountryCode AS CountryCode,
t6.ProductTypeCode AS ProductTypeCode,
t4.CurrentYear AS CurrentYear,
t4.CurrentQuarter AS CurrentQuarter,
t4.CurrentMonth AS CurrentMonth
FROM Sales AS t1
INNER JOIN Retailer AS t2
ON t1.RetailerId = t2.RetailerId
INNER JOIN Product AS t3
ON t1.ProductId = t3.ProductId
INNER JOIN datTime AS t4
ON t1.OrderDay = t4.DayKey
INNER JOIN Region AS t5
ON t2.RetailerCountryCode = t5.CountryCode
INNER JOIN ProductType AS t6
ON t3.ProductTypeId = t6.ProductTypeId
GROUP BY t5.RegionName, t5.CountryCode, t6.ProductTypeCode,
t4.CurrentYear, t4.CurrentQuarter, t4.CurrentMonth;