> ## Documentation Index
> Fetch the complete documentation index at: https://docs.kinetica.com/llms.txt
> Use this file to discover all available pages before exploring further.

# /create/materializedview

```
URL: http://<db.host>:<db.port>/create/materializedview
```

Initiates the process of creating a materialized view, reserving the view's
name to prevent other views or tables from being created with that name.

For materialized view details and examples, see
[Materialized Views](../../concepts/materialized_views/).

The response contains output parameter *view\_id*, which is used to tag each
subsequent operation (projection, union, aggregation, filter, or join) that
will compose the view.

## Input Parameter Description

<ParamField body="table_name" type="string">
  Name of the table to be created that is the top-level table of the materialized view, in \[schema\_name.]table\_name format, using standard [name resolution rules](../../concepts/tables/#table-name-resolution) and meeting [table naming criteria](../../concepts/tables/#table-naming-criteria).
</ParamField>

<ParamField body="options" type="map of string to strings">
  Optional parameters.

  The default value is an empty map ( \{} ).

  <Expandable title="options">
    <ParamField body="collection_name">
      \[DEPRECATED--please specify the containing schema for the materialized view as part of input parameter *table\_name* and use [/create/schema](/content/api/rest/create_schema_rest) to create the schema if non-existent]  Name of a schema which is to contain the newly created view. If the schema provided is non-existent, it will be automatically created.
    </ParamField>

    <ParamField body="execute_as">
      User name to use to run the refresh job.
    </ParamField>

    <ParamField body="build_materialized_view_policy">
      Sets startup materialized view rebuild scheme.

      The default value is `system`.

      * **always**: Rebuild as many materialized views as possible before accepting requests.
      * **lazy**: Rebuild the necessary materialized views at start, and load the remainder lazily.
      * **on\_demand**: Rebuild materialized views as requests use them.
      * **system**: Rebuild materialized views using the system-configured default.
    </ParamField>

    <ParamField body="persist">
      If *true*, then the materialized view specified in input parameter *table\_name* will be persisted and will not expire unless a *ttl* is specified.   If *false*, then the materialized view will be an in-memory table and will expire unless a *ttl* is specified otherwise.

      The default value is `false`.

      The supported values are:

      * true
      * false
    </ParamField>

    <ParamField body="refresh_span">
      Sets the future time-offset(in seconds) at which periodic refresh stops.
    </ParamField>

    <ParamField body="refresh_stop_time">
      When *refresh\_method* is *periodic*, specifies the time at which a periodic refresh is stopped. Value is a datetime string with format 'YYYY-MM-DD HH:MM:SS'.
    </ParamField>

    <ParamField body="refresh_method">
      Method by which the join can be refreshed when the data in underlying member tables have changed.

      The default value is `manual`.

      * **manual**: Refresh only occurs when manually requested by calling [/alter/table](/content/api/rest/alter_table_rest) with an 'action' of 'refresh'.
      * **on\_query**: Refresh any time the view is queried.
      * **on\_change**: If possible, incrementally refresh (refresh just those records added) whenever an insert, update, delete or refresh of input table is done.  A full refresh is done if an incremental refresh is not possible.
      * **periodic**: Refresh table periodically at rate specified by *refresh\_period*.
    </ParamField>

    <ParamField body="refresh_period">
      When *refresh\_method* is *periodic*, specifies the period in seconds at which refresh occurs.
    </ParamField>

    <ParamField body="refresh_start_time">
      When *refresh\_method* is *periodic*, specifies the first time at which a refresh is to be done. Value is a datetime string with format 'YYYY-MM-DD HH:MM:SS'.
    </ParamField>

    <ParamField body="ttl">
      Sets the [TTL](../../concepts/ttl/) of the table specified in input parameter *table\_name*.
    </ParamField>
  </Expandable>
</ParamField>

## Output Parameter Description

The Kinetica server embeds the endpoint response inside a standard response structure which contains status information and the actual response to the query.  Here is a description of the various fields of the wrapper:

<ResponseField name="status" type="String">
  'OK' or 'ERROR'
</ResponseField>

<ResponseField name="message" type="String">
  Empty if success or an error message
</ResponseField>

<ResponseField name="data_type" type="String">
  'create\_materialized\_view\_response' or 'none' in case of an error
</ResponseField>

<ResponseField name="data" type="String">
  Empty string
</ResponseField>

<ResponseField name="data_str" type="JSON or String">
  This embedded JSON represents the result of the /create/materializedview endpoint:

  <Expandable title="data_str">
    <ResponseField name="table_name" type="string">
      Value of input parameter *table\_name*.
    </ResponseField>

    <ResponseField name="view_id" type="string">
      Value of view\_id.
    </ResponseField>

    <ResponseField name="info" type="map of string to strings">
      Additional information.

      The default value is an empty map ( \{} ).

      <Expandable title="info">
        <ResponseField name="qualified_table_name">
          The fully qualified name of the result table (i.e. including the schema).
        </ResponseField>
      </Expandable>
    </ResponseField>
  </Expandable>

  Empty string in case of an error.
</ResponseField>
