How to Create a View in PostgreSQL
Last updated July 24, 2026 · By the SaturnSQL team
Use CREATE OR REPLACE VIEW ... AS SELECT. For expensive queries, CREATE MATERIALIZED VIEW stores the result physically and is refreshed on demand with REFRESH MATERIALIZED VIEW.
CREATE OR REPLACE VIEW active_customers AS
SELECT id, email, last_seen_at
FROM customers
WHERE NOT churned;Materialized view
CREATE MATERIALIZED VIEW daily_revenue AS
SELECT created_at::date AS day, SUM(amount) FROM orders GROUP BY 1;
REFRESH MATERIALIZED VIEW CONCURRENTLY daily_revenue;Run this in SaturnSQL
SaturnSQL is a browser-based SQL editor for teams: shared query library, schema-aware autocomplete, and scheduled exports to Google Sheets and Slack.
Try it free