2
0
mirror of https://github.com/chubin/cheat.sheets synced 2024-11-19 03:25:44 +00:00
cheat.sheets/sheets/_psql/views
2018-01-17 16:13:38 +00:00

26 lines
491 B
Plaintext

-- Create a view
CREATE OR REPLACE view_name AS
query;
-- Create a recurisve view:
CREATE RECURSIVE VIEW view_name(columns) AS
SELECT columns;
-- Create a materialized view:
CREATE MATERIALIZED VIEW view_name
AS
query
WITH [NO] DATA;
-- Refresh a materialized view
REFRESH MATERIALIZED VIEW CONCURRENTLY view_name;
-- Drop a view
DROP VIEW [ IF EXISTS ] view_name;
-- Drop a materialized view
DROP MATERIALIZED VIEW view_name;
-- Rename a view
ALTER VIEW view_name RENAME TO new_name;