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

# Columns

## `core.table.create_column`

Add a column to an existing table.

### Inputs

<ParamField path="column" type="object" required>
  Column definition with required `name` and uppercase `type`, plus optional `nullable`, `default`, and `options` fields. Use `TEXT`, `INTEGER`, `NUMERIC`, `BOOLEAN`, `DATE`, `TIMESTAMPTZ`, `JSONB`, `SELECT`, or `MULTI_SELECT`. `options` is required for `SELECT` and `MULTI_SELECT`.
</ParamField>

<ParamField path="table" type="string" required>
  The table to add the column to.
</ParamField>

### Examples

**Manage table schema**

```yaml theme={null}
- ref: rename_table
  action: core.table.update_table
  args:
    name: asset_inventory
    new_name: assets
- ref: add_owner_team
  action: core.table.create_column
  depends_on:
    - rename_table
  args:
    table: assets
    column:
      name: owner_team
      type: SELECT
      options:
        - secops
        - platform
- ref: drop_owner_team
  action: core.table.delete_column
  depends_on:
    - add_owner_team
  args:
    table: assets
    column: owner_team
```

## `core.table.update_column`

Update a table column's name, type, nullability, default, index, or options.

Set `update: {is_index: true}` to create the table's unique index on
the column. A table can have one single-column unique index:
creation fails if the column already contains duplicate values, and a
second `is_index: true` call raises `Table cannot have multiple
unique indexes`.

Guard the step when a workflow repeats it; see
[Tables](/automations/tables#index-and-upsert).

### Inputs

<ParamField path="column" type="string" required>
  The current column name.
</ParamField>

<ParamField path="table" type="string" required>
  The table containing the column.
</ParamField>

<ParamField path="update" type="object" required>
  Partial column update. Supported fields: `name`, `type`, `nullable`, `default`, `is_index`, and `options`.
</ParamField>

### Examples

**Create a unique index and upsert**

```yaml theme={null}
- ref: ensure_alerts_table
  action: core.table.create_table
  args:
    name: alerts
    columns:
      - name: alert_id
        type: TEXT
      - name: status
        type: TEXT
    raise_on_duplicate: false
- ref: alerts_metadata
  action: core.table.get_table_metadata
  depends_on:
    - ensure_alerts_table
  args:
    name: alerts
- ref: index_alert_id
  action: core.table.update_column
  depends_on:
    - alerts_metadata
  run_if: ${{ FN.length(ACTIONS.alerts_metadata.result.columns[?(@.is_index == true)]) == 0 }}
  args:
    table: alerts
    column: alert_id
    update:
      is_index: true
- ref: upsert_alert
  action: core.table.insert_row
  depends_on:
    - alerts_metadata
    - index_alert_id
  join_strategy: any
  args:
    table: alerts
    upsert: true
    row_data:
      alert_id: ${{ TRIGGER.alert_id }}
      status: ${{ TRIGGER.status }}
```

## `core.table.delete_column`

Delete a column from an existing table.

### Inputs

<ParamField path="column" type="string" required>
  The column name to delete.
</ParamField>

<ParamField path="table" type="string" required>
  The table containing the column.
</ParamField>

### Examples

**Delete a column**

```yaml theme={null}
- ref: drop_owner_team
  action: core.table.delete_column
  args:
    table: assets
    column: owner_team
```
