Materialized Views in Oracle
A materialized view is a database object that stores the results of a query in a table-like format. Materialized views are used to improve query performance and provide a pre-computed view of the data. Here is an example:
CREATE MATERIALIZED VIEW sales_by_region_mv
REFRESH FAST ON COMMIT
AS
SELECT region, SUM(sales_amount) as total_sales
FROM sales
GROUP BY region;
This creates a materialized view named "sales_by_region_mv" that computes the total sales by region from the "sales" table. The "REFRESH FAST ON COMMIT" option specifies that the materialized view should be automatically refreshed whenever the underlying data changes.
No comments:
Post a Comment