Help Center/
GaussDB/
Developer Guide(Distributed_2.x)/
Materialized View/
Full Materialized View/
Usage
Updated on 2023-10-23 GMT+08:00
Usage
Syntax
- Create a full materialized view.
CREATE MATERIALIZED VIEW [ view_name ] AS { query_block };
- Fully refresh a materialized view.
REFRESH MATERIALIZED VIEW [ view_name ];
- Delete a materialized view.
DROP MATERIALIZED VIEW [ view_name ];
- Query a materialized view.
SELECT * FROM [ view_name ];
Examples
-- Prepare data. CREATE TABLE t1(c1 int, c2 int); INSERT INTO t1 VALUES(1, 1); INSERT INTO t1 VALUES(2, 2); -- Create a full materialized view. openGauss=# CREATE MATERIALIZED VIEW mv AS select count(*) from t1; CREATE MATERIALIZED VIEW -- Query the materialized view result. openGauss=# SELECT * FROM mv; count ------- 2 (1 row) -- Insert data into the base table in the materialized view again. openGauss=# INSERT INTO t1 VALUES(3, 3); -- Fully refresh a full materialized view. openGauss=# REFRESH MATERIALIZED VIEW mv; REFRESH MATERIALIZED VIEW -- Query the materialized view result. openGauss=# SELECT * FROM mv; count ------- 3 (1 row) -- Delete a materialized view. openGauss=# DROP MATERIALIZED VIEW mv; DROP MATERIALIZED VIEW
Parent topic: Full Materialized View
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
The system is busy. Please try again later.
For any further questions, feel free to contact us through the chatbot.
Chatbot