mirror of
https://github.com/chubin/cheat.sheets
synced 2024-11-03 15:40:17 +00:00
26 lines
484 B
Plaintext
26 lines
484 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;
|