Database

Views

Save a SELECT as a view, or cache it as a materialized view. Views shape what readers see — joins, aggregates, renamed columns — without copying data.

Creating a view

A view is one SELECT (or WITH … SELECT) query stored under a name. Querying the view runs the query against live data. The editor accepts a single statement up to 16,000 characters.

Example · what the Console creates
CREATE VIEW public.active_customers AS
SELECT id, name, plan
FROM public.customers
WHERE status = 'active';
  • Standard views can be replaced in place (CREATE OR REPLACE) as long as column names and types stay compatible.
  • Views over RLS-protected tables respect the querying role’s policies: the api role sees only the rows its policies allow.
  • The Console lists each view with its definition and columns.

Materialized views

A materialized view runs the query once and stores the result. Reads are fast and constant; the data is a snapshot until you refresh. CubiBase creates them WITH DATA, so they are usable immediately.

ViewMaterialized view
Data freshnessAlways liveAs of the last refresh
Read costRuns the query each timeReads stored rows
Replace in placeYesNo — drop and recreate
Refresh button—Yes: REFRESH MATERIALIZED VIEW

The Data API select switch

Like tables, views start private. The Data API select switch grants SELECT on the view to the api role, so queries executed as that role — inside functions or other views — can read it. Turning the switch off revokes the grant immediately.

Additional resources