Loading subject…
SELECT * FROM SalesSummary works without the user knowing what it joins.CREATE VIEW ItemsWithArtist ASSELECT Item.ItemDesc, Item.ItemCost, Artist.ArtistNameFROM Item JOIN Artist ON Item.ArtistID = Artist.ArtistID;CREATE MATERIALIZED VIEW SalesSummary ASSELECT ProductID, SUM(SalesAmount) AS TotalSalesFROM Sales GROUP BY ProductID;| Feature | Virtual view | Materialized (snapshot) view |
|---|---|---|
| What is stored | The query definition only | The query definition and its result rows |
| Storage cost | Negligible | Grows with the size of the result |
| How current the data is | Always live | As current as the last refresh |
| Read speed | Slower, the query reruns each time | Faster, the rows are already there |
| Maintenance | None beyond the base tables | Needs a refresh schedule |
| Best suited to | Data that changes constantly | Heavy aggregations read far more often than they change |
SELECT * FROM MonthlyReport;CREATE VIEW PublicEmployeeInfo ASSELECT EmployeeID, Name, Position FROM Employees;