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

[Source](https://github.com/kineticadb/kinetica-api-rust/blob/master/crates/gpudb-api/src/generated/create_state_table.rs#L36-L49)
pub async fn [create\_state\_table](https://docs.kinetica.com/content/api/rust/gpudb/struct.Kinetica/create-state-table.md#method.create_state_table)( \&self, table\_name: [String](https://doc.rust-lang.org/1.98.1/alloc/string/struct.String.html), input\_table\_name: [String](https://doc.rust-lang.org/1.98.1/alloc/string/struct.String.html), init\_table\_name: [String](https://doc.rust-lang.org/1.98.1/alloc/string/struct.String.html), ) -> [Result](https://doc.rust-lang.org/1.98.1/core/result/enum.Result.html)\<[CreateStateTableResponse](https://docs.kinetica.com/content/api/rust/generated/api/struct.CreateStateTableResponse.md), [KineticaError](https://docs.kinetica.com/content/api/rust/errors/enum.KineticaError.md)>

Create a table that holds materialized view stateCreates 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.

##### Arguments

<ul>
  <li>`table_name` - Name of the table to be created.</li>
  <li>`input_table_name` - Name of the input table to be copied to the output table on refresh.</li>
  <li>`init_table_name` - Name of the initialization table to be copied to the output table during materialized view creation.</li>
</ul>

[Source](https://github.com/kineticadb/kinetica-api-rust/blob/master/crates/gpudb-api/src/generated/create_state_table.rs#L77-L97)
pub async fn [create\_state\_table\_with\_opts](https://docs.kinetica.com/content/api/rust/gpudb/struct.Kinetica/create-state-table.md#method.create_state_table_with_opts)( \&self, table\_name: [String](https://doc.rust-lang.org/1.98.1/alloc/string/struct.String.html), input\_table\_name: [String](https://doc.rust-lang.org/1.98.1/alloc/string/struct.String.html), init\_table\_name: [String](https://doc.rust-lang.org/1.98.1/alloc/string/struct.String.html), options: [CreateStateTableRequestOptions](https://docs.kinetica.com/content/api/rust/generated/api/struct.CreateStateTableRequestOptions.md), ) -> [Result](https://doc.rust-lang.org/1.98.1/core/result/enum.Result.html)\<[CreateStateTableResponse](https://docs.kinetica.com/content/api/rust/generated/api/struct.CreateStateTableResponse.md), [KineticaError](https://docs.kinetica.com/content/api/rust/errors/enum.KineticaError.md)>

Create a table that holds materialized view stateCreates 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.

##### Arguments

<ul>
  <li>`table_name` - Name of the table to be created.</li>
  <li>`input_table_name` - Name of the input table to be copied to the output table on refresh.</li>
  <li>`init_table_name` - Name of the initialization table to be copied to the output table during materialized view creation.</li>
  <li>`options` - The optional parameters; any left unset take the server’s defaults.</li>
</ul>

[Source](https://github.com/kineticadb/kinetica-api-rust/blob/master/crates/gpudb-api/src/generated/create_state_table.rs#L100-L111)
pub async fn [create\_state\_table\_raw](https://docs.kinetica.com/content/api/rust/gpudb/struct.Kinetica/create-state-table.md#method.create_state_table_raw)( \&self, request: &[CreateStateTableRequest](https://docs.kinetica.com/content/api/rust/generated/api/struct.CreateStateTableRequest.md), ) -> [Result](https://doc.rust-lang.org/1.98.1/core/result/enum.Result.html)\<[CreateStateTableResponse](https://docs.kinetica.com/content/api/rust/generated/api/struct.CreateStateTableResponse.md), [KineticaError](https://docs.kinetica.com/content/api/rust/errors/enum.KineticaError.md)>

Sends a pre-built [`CreateStateTableRequest`](https://docs.kinetica.com/content/api/rust/generated/api/struct.CreateStateTableRequest) to the `/create/statetable` endpoint.

[Source](https://github.com/kineticadb/kinetica-api-rust/blob/master/crates/gpudb-api/src/generated/create_state_table.rs#L115-L127)
pub async fn [create\_state\_table\_from\_url](https://docs.kinetica.com/content/api/rust/gpudb/struct.Kinetica/create-state-table.md#method.create_state_table_from_url)( \&self, url: &[str](https://doc.rust-lang.org/1.98.1/std/primitive.str.html), request: &[CreateStateTableRequest](https://docs.kinetica.com/content/api/rust/generated/api/struct.CreateStateTableRequest.md), ) -> [Result](https://doc.rust-lang.org/1.98.1/core/result/enum.Result.html)\<[CreateStateTableResponse](https://docs.kinetica.com/content/api/rust/generated/api/struct.CreateStateTableResponse.md), [KineticaError](https://docs.kinetica.com/content/api/rust/errors/enum.KineticaError.md)>

Sends a pre-built [`CreateStateTableRequest`](https://docs.kinetica.com/content/api/rust/generated/api/struct.CreateStateTableRequest) to a specific worker URL, bypassing HA head-node selection. Used for multi-head access.


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