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

# Databases

> Create and manage internal data stores for your automation workflows

## What are Automation Databases?

Automation databases are internal, isolated data stores that live within the Automations section. They are completely separate from the main Royaltyport database and provide dedicated storage for your workflow data — staging tables, lookup data, intermediate results, and more.

## Creating a Database

Database creation is a two-step wizard:

<Steps>
  <Step title="Configure the Database">
    Enter a name (the `db:` prefix is added automatically), an optional description, select the region, scope (organization or project), and mode (test or live).
  </Step>

  <Step title="Define Tables">
    Add tables with columns. For each column, specify the data type and optional constraints (nullable, unique, default value). Every table automatically includes `id`, `created_at`, and `updated_at` columns.
  </Step>
</Steps>

### Regions

Choose from multiple AWS and Azure regions worldwide:

| Provider  | Regions                                                                                                                                |
| --------- | -------------------------------------------------------------------------------------------------------------------------------------- |
| **AWS**   | US East (N. Virginia, Ohio), US West (Oregon), Europe (Frankfurt, London), Asia Pacific (Singapore, Sydney), South America (Sao Paulo) |
| **Azure** | East US 2 (Virginia), West US 3 (Arizona), Germany West Central (Frankfurt)                                                            |

### Scope

| Scope            | Description                                                   |
| ---------------- | ------------------------------------------------------------- |
| **Organization** | Database is available across all projects in the organization |
| **Project**      | Database is only available in the current project             |

## Editing a Database

Click on a database to open the fullscreen editor. The editor has three parts: a **table sidebar** on the left, a **toolbar** at the top, and a **view area** in the center.

### Table Sidebar

The sidebar lists all tables in the database.

* **Create a table** — click the **+** button, type a name inline, and press Enter
* **Delete a table** — click the delete icon next to a table name and confirm in the dialog
* **Switch tables** — click any table name to load it in the view area

### Content View

The content view is the default. It shows a paginated grid of records (50 per page).

**Browsing**

* Use the pagination controls in the toolbar to move between pages
* Click the **Refresh** button to sync the database schema and reload data

<Note>
  Clicking **Refresh** does more than reload records — it re-introspects the connected database to discover new tables, update column definitions, and remove tables that no longer exist. This keeps Royaltyport's view of your database in sync if the schema has changed outside the editor (for example, after running migrations). If the Definitions panel is open, it is also refreshed.
</Note>

**Adding records**

* Click **Add Record** in the toolbar to insert a new empty row
* Fill in the editable cells — system columns (`id`, `created_at`, `updated_at`) are read-only

**Editing records**

* Click any editable cell to enter edit mode
* Press **Enter** to save the change, or **Escape** to cancel
* Vector columns display a `[vector]` placeholder and cannot be edited inline

**Deleting records**

* Select rows using the checkbox on each row, or use the header checkbox to select all on the current page
* Click the **Delete** button in the toolbar — it shows the number of selected rows
* Confirm the deletion in the dialog

### Definitions View

Toggle to the **Definitions** view using the toolbar switch. This view shows the schema structure of the selected table.

**Columns**

* Each column shows its name, data type, and constraints (nullable, unique, default)
* System columns (`id`, `created_at`, `updated_at`) are pinned to the top and cannot be removed
* Drag and drop columns to reorder them

**Adding a column**

* Click **Add Column** in the toolbar
* Fill in the inline form: name, data type, default value (optional), and toggles for **nullable** and **unique**
* Confirm to add the column to the table

**Dropping a column**

* Click the delete icon next to a column
* Confirm in the dialog — this permanently removes the column and all its data

**Constraints & Indexes**

* View existing constraints and indexes below the column list

## Access Levels

Each database and table can have granular access levels:

| Level      | Permission                         |
| ---------- | ---------------------------------- |
| **Read**   | Query and browse data              |
| **Write**  | Insert, update, and upsert records |
| **Delete** | Remove records                     |

## Using Databases in Steps

In a [Database step](/automations/steps/database), select your automation database from the dropdown. The step supports Read, Insert, Update, Upsert, Delete, and raw SQL Query operations.

Reference database data in other steps using the template variable syntax: `{{db:{name}.{table}[]}}`.

## Mode Scoping

Databases are scoped per mode, just like secrets:

* **Test databases** are used during test executions
* **Live databases** are used during production executions
* During [deployment](/automations/test-and-deploy), you choose which databases to copy to the live environment

## Deleting Databases

Databases can only be deleted in test mode.

<Warning>
  Deleting a database permanently removes all tables and data. This cannot be undone.
</Warning>

## Related Documentation

<CardGroup cols={2}>
  <Card title="Steps" icon="puzzle" href="/automations/steps/overview">
    Use the Database step type to query automation databases.
  </Card>

  <Card title="Test & Deploy" icon="rocket" href="/automations/test-and-deploy">
    Databases are copied from test to live during deployment.
  </Card>
</CardGroup>
