OriginChainDB
Database endpoints

Create a materialized view

Creates a materialized view from a SQL SELECT and materializes its initial contents.

POST /v1/tenants/{tenant}/sql/materialized-views

Save a query result as a viewAn on-demand view needs refreshes to reflect later source changes.
  1. Define the view querySupply SELECT, source table and refresh mode.
  2. Materialize the initial resultStore the rows produced by that query.
  3. Inspect rows and refresh timeUse the counts and timestamp to verify creation.

Before you start

Use your database bearer token.

Connection setup

Create and populate the source table before creating its view. The example reads demo.people.

Path parameters

FieldTypeRequired
tenantstringRequired

Headers

FieldTypeRequiredDescription
x-oc-db-userstringOptionalActing database user (role, grant and row-policy checks). Send with x-oc-db-key.
x-oc-db-keystringOptionalAPI key of the x-oc-db-user user.

Request body

application/json

Limits and accepted values
  • refresh_mode is "on_demand" (default;
  • stale until refreshed) or "incremental" (maintained on every write;
  • only filter/projection views and COUNT/SUM/AVG rollups qualify, otherwise 422).
  • source_schema optionally names the base table as "namespace.table" and must agree with the query's FROM.
  • auto=true chooses incremental when the query shape allows it and on_demand otherwise. 409 when the name already exists.
FieldTypeRequired
namestringRequired
querystringRequired
refresh_modestringOptional
source_schemastringOptional

Read the result

rows_materialized reports the initial stored rows and refresh_ts identifies the refresh. An on_demand view becomes stale until refreshed; choosing it does not keep the view current automatically.

Response statuses

HTTP status reference
StatusWhat to do
200OK
400Correct the request before retrying.
401Check the credential and Authorization header.
402Check feature access or available credits.
403Check tenant access, roles and permissions.
409Resolve the conflict before retrying.
413Split or reduce the request body.
415Send the required Content-Type.
422Correct the values or unsupported combination.
429Honor Retry-After when present; back off.
500Check the outcome before retrying a write.
501Check deployment support for this operation.
502Check service availability and the write outcome.
503Honor Retry-After when present; check write outcomes.
ยฉ 2026 Silicoyn Technologies Pvt Ltd