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

### create\_state\_table

<ul>
  <li>
    create\_state\_table(\
    &#x20;table\_name: string,\
    &#x20;input\_table\_name: string,\
    &#x20;init\_table\_name: string,\
    &#x20;options?: Record\<string, string>,\
    &#x20;callback?: [GPUdbCallback](https://docs.kinetica.com/content/api/typescript/types/GPUdbCallback.md),\
    ): Promise\<[CreateStateTableResponse](https://docs.kinetica.com/content/api/typescript/interfaces/CreateStateTableResponse.md)>

    Creates a state table in a materialized view allowing a materialized view to maintain state between refreshes. The state table must be a materialized view member. The state table can be part of a feedback loop including input\_table\_name. To facilitate such feedback loops the create\_state\_table can be called before the input\_table\_name is created but must be created after init\_table\_name is created. During the initial call to create the state table init\_table\_name is copied to table\_name, setting the initial state output of the table. On refresh the create\_state\_table runs before the endpoint that creates the input\_table\_name and copies the input\_table\_name to table\_name, setting the state to the version of the input\_table from the last refresh. A materialized view is not complete (ready to refresh and query) until both the root table of the view is created and all the input tables to the state tables have been created.

    #### Parameters

    <ul>
      <li>
        table\_name: string

        Name of the table to be created.
      </li>

      <li>
        input\_table\_name: string

        Name of the input table to be copied to the output table on refresh.
      </li>

      <li>
        init\_table\_name: string

        Name of the initialization table to be copied to the output table during materialized view creation.
      </li>

      <li>
        `Optional`options: Record\<string, string>

        Optional parameters.
      </li>

      <li>
        `Optional`callback: [GPUdbCallback](https://docs.kinetica.com/content/api/typescript/types/GPUdbCallback.md)

        Optional callback function
      </li>
    </ul>

    #### Returns Promise\<[CreateStateTableResponse](https://docs.kinetica.com/content/api/typescript/interfaces/CreateStateTableResponse.md)>

    Promise\<Types.CreateStateTableResponse> - Promise resolving to the response

    <ul>
      <li>Defined in [src/GPUdb.ts:6825](https://github.com/kineticadb/kinetica-api-typescript/blob/master/src/GPUdb.ts#L6825)</li>
    </ul>
  </li>
</ul>

### create\_state\_table\_request

<ul>
  <li>
    create\_state\_table\_request(\
    &#x20;request: [CreateStateTableRequest](https://docs.kinetica.com/content/api/typescript/interfaces/CreateStateTableRequest.md),\
    &#x20;callback?: [GPUdbCallback](https://docs.kinetica.com/content/api/typescript/types/GPUdbCallback.md),\
    ): Promise\<[CreateStateTableResponse](https://docs.kinetica.com/content/api/typescript/interfaces/CreateStateTableResponse.md)>

    Creates a state table in a materialized view allowing a materialized view to maintain state between refreshes. The state table must be a materialized view member. The state table can be part of a feedback loop including input\_table\_name. To facilitate such feedback loops the create\_state\_table can be called before the input\_table\_name is created but must be created after init\_table\_name is created. During the initial call to create the state table init\_table\_name is copied to table\_name, setting the initial state output of the table. On refresh the create\_state\_table runs before the endpoint that creates the input\_table\_name and copies the input\_table\_name to table\_name, setting the state to the version of the input\_table from the last refresh. A materialized view is not complete (ready to refresh and query) until both the root table of the view is created and all the input tables to the state tables have been created.

    #### Parameters

    <ul>
      <li>
        request: [CreateStateTableRequest](https://docs.kinetica.com/content/api/typescript/interfaces/CreateStateTableRequest.md)

        Request object containing the parameters for the operation
      </li>

      <li>
        `Optional`callback: [GPUdbCallback](https://docs.kinetica.com/content/api/typescript/types/GPUdbCallback.md)

        Optional callback function
      </li>
    </ul>

    #### Returns Promise\<[CreateStateTableResponse](https://docs.kinetica.com/content/api/typescript/interfaces/CreateStateTableResponse.md)>

    Promise\<Types.CreateStateTableResponse> - Promise resolving to the response

    <ul>
      <li>Defined in [src/GPUdb.ts:6785](https://github.com/kineticadb/kinetica-api-typescript/blob/master/src/GPUdb.ts#L6785)</li>
    </ul>
  </li>
</ul>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.