2
0
mirror of https://github.com/chubin/cheat.sheets synced 2024-11-03 15:40:17 +00:00
cheat.sheets/sheets/_psql/views

26 lines
484 B
Plaintext
Raw Normal View History

2018-01-07 11:42:08 +00:00
# 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;