Also available: Markdown version · llms.txt · full site content
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.
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.
| View | Materialized view | |
|---|---|---|
| Data freshness | Always live | As of the last refresh |
| Read cost | Runs the query each time | Reads stored rows |
| Replace in place | Yes | No — 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.