2018-01-17 16:13:38 +00:00
|
|
|
-- Create a view
|
2018-01-07 11:42:08 +00:00
|
|
|
CREATE OR REPLACE view_name AS
|
|
|
|
query;
|
|
|
|
|
2018-01-17 16:13:38 +00:00
|
|
|
-- Create a recurisve view:
|
2018-01-07 11:42:08 +00:00
|
|
|
CREATE RECURSIVE VIEW view_name(columns) AS
|
|
|
|
SELECT columns;
|
|
|
|
|
2018-01-17 16:13:38 +00:00
|
|
|
-- Create a materialized view:
|
2018-01-07 11:42:08 +00:00
|
|
|
CREATE MATERIALIZED VIEW view_name
|
|
|
|
AS
|
|
|
|
query
|
|
|
|
WITH [NO] DATA;
|
|
|
|
|
2018-01-17 16:13:38 +00:00
|
|
|
-- Refresh a materialized view
|
2018-01-07 11:42:08 +00:00
|
|
|
REFRESH MATERIALIZED VIEW CONCURRENTLY view_name;
|
|
|
|
|
2018-01-17 16:13:38 +00:00
|
|
|
-- Drop a view
|
2018-01-07 11:42:08 +00:00
|
|
|
DROP VIEW [ IF EXISTS ] view_name;
|
|
|
|
|
2018-01-17 16:13:38 +00:00
|
|
|
-- Drop a materialized view
|
2018-01-07 11:42:08 +00:00
|
|
|
DROP MATERIALIZED VIEW view_name;
|
|
|
|
|
2018-01-17 16:13:38 +00:00
|
|
|
-- Rename a view
|
2018-01-07 11:42:08 +00:00
|
|
|
ALTER VIEW view_name RENAME TO new_name;
|