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

# Manage Data Store

> Create and evolve the tables, columns, indexes, and views of a structured knowledge base

## What it does

`manage_data_store` lets an agent shape the schema of a [data store](/features/data-stores)
(a structured knowledge base): create tables, add or alter columns, add indexes,
create views, and inspect the current schema. Changes apply to the store's own
isolated Postgres database.

<Info>
  For an overview of structured data stores — what they are and when to use one —
  see [Data Stores](/features/data-stores).
</Info>

## Parameters

| Parameter           | Type    | Required                      | Description                                                                                                                              |
| ------------------- | ------- | ----------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
| `knowledge_base_id` | integer | Yes                           | The structured knowledge base to modify                                                                                                  |
| `operation`         | string  | Yes                           | One of `create_table`, `add_column`, `alter_column`, `create_index`, `create_view`, `drop_column`, `drop_table`, `drop_view`, `describe` |
| `table`             | string  | For most ops                  | Table (or view) name — lowercase snake\_case                                                                                             |
| `columns`           | array   | `create_table`, `add_column`  | Column definitions (`name`, `type`, `nullable`, `default`, `primary_key`)                                                                |
| `column`            | string  | `alter_column`, `drop_column` | Target column                                                                                                                            |
| `new_type`          | string  | `alter_column`                | New column type                                                                                                                          |
| `index_columns`     | array   | `create_index`                | Columns to index                                                                                                                         |
| `unique`            | boolean | No                            | Make a `create_index` unique                                                                                                             |
| `view_sql`          | string  | `create_view`                 | A full `SELECT` computed server-side (joins, aggregates, window functions, CTEs)                                                         |
| `confirm`           | boolean | For drops                     | Required `true` for `drop_column`, `drop_table`, `drop_view`                                                                             |

## Key behaviors

* **A primary key is added for you.** `create_table` adds an `id` primary key
  automatically unless you define your own.
* **Views give apps aggregation power.** `create_view` stores an agent-authored
  `SELECT` that apps read like a table — the way to let an app show a rollup or
  join over a large table without pulling every row. Views run with the reading
  role's privileges, so they stay safely scoped to the store.
* **Destructive changes are gated.** Dropping a column, table, or view requires
  `confirm: true`, because a published app may depend on it.
* **Every change is audited**, and the store's cached schema — which the agent
  sees in its context — refreshes automatically after each change.

## Common use cases

### Create a table

```
operation: create_table
knowledge_base_id: 954
table: project_stages
columns:
  - { name: stage_name, type: text, nullable: false }
  - { name: status, type: text, nullable: false }
  - { name: sort_order, type: integer, nullable: false }
```

### Create a view for an app to chart

```
operation: create_view
knowledge_base_id: 954
table: stage_summary
view_sql: SELECT status, count(*) AS n FROM project_stages GROUP BY status
```

## Related

* [Query Data Store](/tools/query_data_store) — read data with SQL
* [Write Data Store](/tools/write_data_store) — insert, update, delete, upsert
* [Data Stores](/features/data-stores) — the feature overview
