> ## 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.

# createMaterializedView

<div className="kinetica-javadoc">
  <ul className="member-list">
    <li>
      <div className="section detail" id="createMaterializedView(com.gpudb.protocol.CreateMaterializedViewRequest)">
        <h3>createMaterializedView</h3>
        <div className="member-signature"><span className="modifiers">public</span> <span className="return-type"><a href="/content/api/java/com/gpudb/protocol/CreateMaterializedViewResponse" title="class in com.gpudb.protocol">CreateMaterializedViewResponse</a></span> <span className="element-name">createMaterializedView</span><wbr /><span className="parameters">(<a href="/content/api/java/com/gpudb/protocol/CreateMaterializedViewRequest" title="class in com.gpudb.protocol">CreateMaterializedViewRequest</a> request)</span> throws <span className="exceptions"><a href="/content/api/java/com/gpudb/GPUdbException" title="class in com.gpudb">GPUdbException</a></span></div>

        <div className="block">
          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.
          <p> For materialized view details and examples, see <a href="/content/concepts/materialized_views/" target="_top">Materialized Views</a>. </p>
          <p> The response contains <a href="/content/api/java/com/gpudb/protocol/CreateMaterializedViewResponse#getViewId()"><code>viewId</code></a>, which is used to tag each subsequent operation (projection, union, aggregation, filter, or join) that will compose the view.</p>
        </div>

        <div className="dl notes">
          <div className="dt">Parameters:</div>
          <div className="dd"><code>request</code> - <a href="/content/api/java/com/gpudb/protocol/CreateMaterializedViewRequest" title="class in com.gpudb.protocol"><code>Request</code></a> object containing the parameters for the operation.</div>
          <div className="dt">Returns:</div>
          <div className="dd"><a href="/content/api/java/com/gpudb/protocol/CreateMaterializedViewResponse" title="class in com.gpudb.protocol"><code>Response</code></a> object containing the results of the operation.</div>
          <div className="dt">Throws:</div>
          <div className="dd"><code><a href="/content/api/java/com/gpudb/GPUdbException" title="class in com.gpudb">GPUdbException</a></code> - if an error occurs during the operation.</div>
        </div>
      </div>
    </li>

    <li>
      <div className="section detail" id="createMaterializedView(java.lang.String,java.util.Map)">
        <h3>createMaterializedView</h3>
        <div className="member-signature"><span className="modifiers">public</span> <span className="return-type"><a href="/content/api/java/com/gpudb/protocol/CreateMaterializedViewResponse" title="class in com.gpudb.protocol">CreateMaterializedViewResponse</a></span> <span className="element-name">createMaterializedView</span><wbr /><span className="parameters">(<a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/String.html" title="class or interface in java.lang" className="external-link">String</a> tableName, <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/Map.html" title="class or interface in java.util" className="external-link">Map</a>\<<a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/String.html" title="class or interface in java.lang" className="external-link">String</a>,<wbr /><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/String.html" title="class or interface in java.lang" className="external-link">String</a>> options)</span> throws <span className="exceptions"><a href="/content/api/java/com/gpudb/GPUdbException" title="class in com.gpudb">GPUdbException</a></span></div>

        <div className="block">
          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.
          <p> For materialized view details and examples, see <a href="/content/concepts/materialized_views/" target="_top">Materialized Views</a>. </p>
          <p> The response contains <a href="/content/api/java/com/gpudb/protocol/CreateMaterializedViewResponse#getViewId()"><code>viewId</code></a>, which is used to tag each subsequent operation (projection, union, aggregation, filter, or join) that will compose the view.</p>
        </div>

        <div className="dl notes">
          <div className="dt">Parameters:</div>
          <div className="dd"><code>tableName</code> - 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 <a href="/content/concepts/tables/#table-name-resolution" target="_top">name resolution rules</a> and meeting <a href="/content/concepts/tables/#table-naming-criteria" target="_top">table naming criteria</a>.</div>

          <div className="dd">
            <code>options</code> - Optional parameters.

            <ul>
              <li><a href="/content/api/java/com/gpudb/protocol/CreateMaterializedViewRequest.Options#COLLECTION_NAME"><code>COLLECTION\_NAME</code></a>: \[DEPRECATED--please specify the containing schema for the materialized view as part of <code>tableName</code> and use <a href="#createSchema(java.lang.String,java.util.Map)"><code>createSchema</code></a> 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. </li>
              <li><a href="/content/api/java/com/gpudb/protocol/CreateMaterializedViewRequest.Options#EXECUTE_AS"><code>EXECUTE\_AS</code></a>: User name to use to run the refresh job. </li>

              <li>
                <a href="/content/api/java/com/gpudb/protocol/CreateMaterializedViewRequest.Options#BUILD_MATERIALIZED_VIEW_POLICY"><code>BUILD\_MATERIALIZED\_VIEW\_POLICY</code></a>: Sets startup materialized view rebuild scheme. Supported values:

                <ul>
                  <li><a href="/content/api/java/com/gpudb/protocol/CreateMaterializedViewRequest.Options#ALWAYS"><code>ALWAYS</code></a>: Rebuild as many materialized views as possible before accepting requests. </li>
                  <li><a href="/content/api/java/com/gpudb/protocol/CreateMaterializedViewRequest.Options#LAZY"><code>LAZY</code></a>: Rebuild the necessary materialized views at start, and load the remainder lazily. </li>
                  <li><a href="/content/api/java/com/gpudb/protocol/CreateMaterializedViewRequest.Options#ON_DEMAND"><code>ON\_DEMAND</code></a>: Rebuild materialized views as requests use them. </li>
                  <li><a href="/content/api/java/com/gpudb/protocol/CreateMaterializedViewRequest.Options#SYSTEM"><code>SYSTEM</code></a>: Rebuild materialized views using the system-configured default. </li>
                </ul>

                The default value is <a href="/content/api/java/com/gpudb/protocol/CreateMaterializedViewRequest.Options#SYSTEM"><code>SYSTEM</code></a>.
              </li>

              <li>
                <a href="/content/api/java/com/gpudb/protocol/CreateMaterializedViewRequest.Options#PERSIST"><code>PERSIST</code></a>: If <a href="/content/api/java/com/gpudb/protocol/CreateMaterializedViewRequest.Options#TRUE"><code>TRUE</code></a>, then the materialized view specified in <code>tableName</code> will be persisted and will not expire unless a <a href="/content/api/java/com/gpudb/protocol/CreateMaterializedViewRequest.Options#TTL"><code>TTL</code></a> is specified. If <a href="/content/api/java/com/gpudb/protocol/CreateMaterializedViewRequest.Options#FALSE"><code>FALSE</code></a>, then the materialized view will be an in-memory table and will expire unless a <a href="/content/api/java/com/gpudb/protocol/CreateMaterializedViewRequest.Options#TTL"><code>TTL</code></a> is specified otherwise. Supported values:

                <ul>
                  <li><a href="/content/api/java/com/gpudb/protocol/CreateMaterializedViewRequest.Options#TRUE"><code>TRUE</code></a> </li>
                  <li><a href="/content/api/java/com/gpudb/protocol/CreateMaterializedViewRequest.Options#FALSE"><code>FALSE</code></a> </li>
                </ul>

                The default value is <a href="/content/api/java/com/gpudb/protocol/CreateMaterializedViewRequest.Options#FALSE"><code>FALSE</code></a>.
              </li>

              <li>
                <a href="/content/api/java/com/gpudb/protocol/CreateMaterializedViewRequest.Options#ENABLE_MV_INPUT_WRAPPERS"><code>ENABLE\_MV\_INPUT\_WRAPPERS</code></a>: If <a href="/content/api/java/com/gpudb/protocol/CreateMaterializedViewRequest.Options#TRUE"><code>TRUE</code></a>, each base table the view reads is accessed through a wrapper view so an in-progress out-of-place update cannot make a record momentarily disappear from the view, and a long refresh does not block updates to the base tables. Overrides the {"{"}gaia.enable\_mv\_input\_wrappers{"}"} configuration default when set. Supported values:

                <ul>
                  <li><a href="/content/api/java/com/gpudb/protocol/CreateMaterializedViewRequest.Options#TRUE"><code>TRUE</code></a> </li>
                  <li><a href="/content/api/java/com/gpudb/protocol/CreateMaterializedViewRequest.Options#FALSE"><code>FALSE</code></a> </li>
                </ul>

                The default value is <a href="/content/api/java/com/gpudb/protocol/CreateMaterializedViewRequest.Options#FALSE"><code>FALSE</code></a>.
              </li>

              <li><a href="/content/api/java/com/gpudb/protocol/CreateMaterializedViewRequest.Options#REFRESH_SPAN"><code>REFRESH\_SPAN</code></a>: Sets the future time-offset(in seconds) at which periodic refresh stops. </li>
              <li><a href="/content/api/java/com/gpudb/protocol/CreateMaterializedViewRequest.Options#REFRESH_STOP_TIME"><code>REFRESH\_STOP\_TIME</code></a>: When <a href="/content/api/java/com/gpudb/protocol/CreateMaterializedViewRequest.Options#REFRESH_METHOD"><code>REFRESH\_METHOD</code></a> is <a href="/content/api/java/com/gpudb/protocol/CreateMaterializedViewRequest.Options#PERIODIC"><code>PERIODIC</code></a>, specifies the time at which a periodic refresh is stopped. Value is a datetime string with format 'YYYY-MM-DD HH:MM:SS'. </li>

              <li>
                <a href="/content/api/java/com/gpudb/protocol/CreateMaterializedViewRequest.Options#REFRESH_METHOD"><code>REFRESH\_METHOD</code></a>: Method by which the join can be refreshed when the data in underlying member tables have changed. Supported values:

                <ul>
                  <li><a href="/content/api/java/com/gpudb/protocol/CreateMaterializedViewRequest.Options#MANUAL"><code>MANUAL</code></a>: Refresh only occurs when manually requested by calling <a href="#alterTable(java.lang.String,java.lang.String,java.lang.String,java.util.Map)"><code>alterTable</code></a> with an 'action' of 'refresh'. </li>
                  <li><a href="/content/api/java/com/gpudb/protocol/CreateMaterializedViewRequest.Options#ON_QUERY"><code>ON\_QUERY</code></a>: Refresh any time the view is queried. </li>
                  <li><a href="/content/api/java/com/gpudb/protocol/CreateMaterializedViewRequest.Options#ON_CHANGE"><code>ON\_CHANGE</code></a>: 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. </li>
                  <li><a href="/content/api/java/com/gpudb/protocol/CreateMaterializedViewRequest.Options#PERIODIC"><code>PERIODIC</code></a>: Refresh table periodically at rate specified by <a href="/content/api/java/com/gpudb/protocol/CreateMaterializedViewRequest.Options#REFRESH_PERIOD"><code>REFRESH\_PERIOD</code></a>. </li>
                </ul>

                The default value is <a href="/content/api/java/com/gpudb/protocol/CreateMaterializedViewRequest.Options#MANUAL"><code>MANUAL</code></a>.
              </li>

              <li><a href="/content/api/java/com/gpudb/protocol/CreateMaterializedViewRequest.Options#REFRESH_PERIOD"><code>REFRESH\_PERIOD</code></a>: When <a href="/content/api/java/com/gpudb/protocol/CreateMaterializedViewRequest.Options#REFRESH_METHOD"><code>REFRESH\_METHOD</code></a> is <a href="/content/api/java/com/gpudb/protocol/CreateMaterializedViewRequest.Options#PERIODIC"><code>PERIODIC</code></a>, specifies the period in seconds at which refresh occurs. </li>
              <li><a href="/content/api/java/com/gpudb/protocol/CreateMaterializedViewRequest.Options#REFRESH_START_TIME"><code>REFRESH\_START\_TIME</code></a>: When <a href="/content/api/java/com/gpudb/protocol/CreateMaterializedViewRequest.Options#REFRESH_METHOD"><code>REFRESH\_METHOD</code></a> is <a href="/content/api/java/com/gpudb/protocol/CreateMaterializedViewRequest.Options#PERIODIC"><code>PERIODIC</code></a>, 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'. </li>
              <li><a href="/content/api/java/com/gpudb/protocol/CreateMaterializedViewRequest.Options#TTL"><code>TTL</code></a>: Sets the <a href="/content/concepts/ttl/" target="_top">TTL</a> of the table specified in <code>tableName</code>. </li>
            </ul>

            The default value is an empty <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/Map.html" title="class or interface in java.util" className="external-link"><code>Map</code></a>.
          </div>

          <div className="dt">Returns:</div>
          <div className="dd"><a href="/content/api/java/com/gpudb/protocol/CreateMaterializedViewResponse" title="class in com.gpudb.protocol"><code>Response</code></a> object containing the results of the operation.</div>
          <div className="dt">Throws:</div>
          <div className="dd"><code><a href="/content/api/java/com/gpudb/GPUdbException" title="class in com.gpudb">GPUdbException</a></code> - if an error occurs during the operation.</div>
        </div>
      </div>
    </li>
  </ul>
</div>
