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

# Databases

> Built-in PostgreSQL database for every Anything project

<a id="database-overview-video" />

<div style={{position: 'relative', paddingBottom: '56.25%', height: 0}}>
  <iframe src="https://www.loom.com/embed/fb688b52623b46d5b8f0a9eefb42d3dc" title="Database Overview Video" frameBorder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; fullscreen" allowFullScreen webkitallowfullscreen="true" mozallowfullscreen="true" style={{position: 'absolute', top: 0, left: 0, width: '100%', height: '100%'}} />
</div>

Every project gets two databases: one for development, one for production. Anything handles the structure, the queries, and the code. You just describe what you want to store.

Your database runs on PostgreSQL (via [Neon](https://neon.tech)) and scales automatically as your app grows.

<Note>
  **Development vs. production:** When you publish, Anything pushes the database structure (tables and fields) to production, but data stays separate. Test data you create while building won't appear in your live app. This protects your production data while you experiment.
</Note>

## How it works

When a feature needs data, Anything:

1. Designs the database structure
2. Creates [Functions](/apps/backend) to save and retrieve data
3. Builds pages and components to display it
4. Wires everything together

### Example

Say "make me a tasks app" and Anything:

<Steps>
  <Step title="Creates a tasks table with title, due date, and other fields">
    <Frame>
      <img src="https://mintcdn.com/create/FQ38N__i9RkapQvc/images/databases/viewer.png?fit=max&auto=format&n=FQ38N__i9RkapQvc&q=85&s=8925bf68dccefeb63344c479fde9ed4c" width="3456" height="1916" data-path="images/databases/viewer.png" />
    </Frame>
  </Step>

  <Step title="Creates Functions to save and fetch tasks">
    <Frame>
      <img src="https://mintcdn.com/create/FQ38N__i9RkapQvc/images/databases/tasks-functions.png?fit=max&auto=format&n=FQ38N__i9RkapQvc&q=85&s=d993e3b469ba98d41b404317f342025b" width="3456" height="1916" data-path="images/databases/tasks-functions.png" />
    </Frame>
  </Step>

  <Step title="Builds a Page with a task list and add form">
    <Frame>
      <img src="https://mintcdn.com/create/FQ38N__i9RkapQvc/images/databases/tasks-ui.png?fit=max&auto=format&n=FQ38N__i9RkapQvc&q=85&s=8b8a25ffeed3bbfffca2cc44c37660b5" width="3456" height="1918" data-path="images/databases/tasks-ui.png" />
    </Frame>
  </Step>

  <Step title="Makes your Page use your Functions to save and grab tasks from the database">
    <Frame>
      <img src="https://mintcdn.com/create/FQ38N__i9RkapQvc/images/databases/tasks-connected.png?fit=max&auto=format&n=FQ38N__i9RkapQvc&q=85&s=1a91cfcc9824e6a407c774950b6b59c3" width="3456" height="1916" data-path="images/databases/tasks-connected.png" />
    </Frame>
  </Step>
</Steps>

As you keep building, Anything updates the database structure, functions, and pages to match.

## Common changes

Describe what you want and Anything handles the database updates.

```
Add a description to todos. Show it below the title in italics.
```

```
Remove the priority from todos, we won't use it anymore
```

```
Let users add comments on todos. Each comment should have the text and who wrote it
```

```
Instead of due dates, let's use status (Todo, In Progress, Done) to track progress
```

```
Generate 10 sample todos with different statuses and assignees
```

```
Make sure every todo has a title
```

<Tip>
  The more specific you are, the better. "Make a todo app" works, but "make a todo app with a title, due date, and priority field" gives you exactly what you want.
</Tip>

## Database viewer

The built-in database viewer lets you see your data, edit rows, sort, filter, and run SQL queries. Open it from the [Project Selector](/builder/controls#project-selector) or tap a database mention in chat.

<Info>
  Demo mode uses the development database. Your live data stays untouched while you experiment.
</Info>

## Publishing

When you publish, Anything pushes the database structure (tables and fields) from development to production. Data stays separate.

<Warning>
  If you remove a field in development that exists in your live database (like a phone number column with real data), Anything warns you before publishing. You can either keep the field or accept the data loss.
</Warning>

## Troubleshooting

If data isn't saving, check these three things in order:

1. **Database structure** — open the viewer and verify your tables and fields look right. If not, describe the correct structure in chat.
2. **Functions** — ask the agent to test the function that saves data. If it errors, paste the error into chat.
3. **Page to function** — try the app in Demo mode and watch the database viewer. If records don't appear, tell the agent what should happen (e.g., "submitting the form should save a task").

<Tip>
  Paste any error message directly into chat. Anything recognizes common patterns and can usually fix them.
</Tip>

## Reset database structure

If you've made changes to your development database and want to undo them, you can reset to the structure of your last published version.

1. Open the database viewer
2. Click **Reset** in the top right
3. Confirm

<Warning>
  Resetting removes all structure changes since your last publish. Any tables or fields you added since then (and their data) will be lost.
</Warning>

## Duplicate a project with data

When you duplicate a project from the dashboard, you can choose whether to include database data in the copy. A dialog lets you pick development data, production data, both, or neither. The database structure (tables and fields) is always copied.

This is useful for creating a staging version of a live app or starting a new version with real data to test against.

## Use an existing database

If you already have data in another project's database and want to reuse it:

1. Open your new project
2. Press `/` > **Databases** > select the database
3. Describe what you want to build

Both projects will share the same data. This is useful for building an admin tool alongside a customer-facing app.

## Change or remove a project's database

Most projects only need one database. A single database can hold as many tables as you want, and that's easier to work with than juggling several.

There are two ways to manage which projects a database connects to:

* **Remove the database from the project you're in.** In the database panel, click **Remove** in the top bar and confirm. This unlinks the database from the current project.
* **Add, switch, or remove across projects.** Open the full database viewer (the open-in-new-tab icon on the database panel), click the three-dot menu in the top right, and choose **Manage projects**. From there you can add a project by searching its name, or remove one with the X next to it.

A project can only have one database at a time. If a project already has one, unlink that database before linking a new one.

<Note>
  Removing a database from a project makes it inaccessible there but doesn't delete it. Your production data stays intact.
</Note>

## Export

Export your entire database as a ZIP file containing SQL dumps for both development and production.

1. Open the database viewer
2. Click **Export database**
3. You'll get an email when the export is ready

The ZIP includes `development.sql` and `production.sql` with your full database structure and data.

## FAQ

<AccordionGroup>
  <Accordion title="Will this scale?">
    Yes. Every database runs on PostgreSQL via [Neon](https://neon.tech) and autoscales as your app grows.
  </Accordion>

  <Accordion title="How much data can I store?">
    Free plans include 1 GB of storage. Pro plans get 10 GB. Business and Enterprise get 100 GB. [Upgrade your plan](/account/subscriptions) if you need more.
  </Accordion>

  <Accordion title="Can I export my data?">
    Yes. Click **Export database** in the database viewer to download a ZIP with SQL files for development and production. See [Export](#export).
  </Accordion>

  <Accordion title="Can I import existing data?">
    Not yet. Import is coming in a future update.
  </Accordion>

  <Accordion title="How do I connect to external databases?">
    Use [Functions](/apps/backend) to connect to external databases like Supabase or your own backend.
  </Accordion>

  <Accordion title="Is my data backed up?">
    Yes. Databases are automatically backed up. Email [hello@anything.com](mailto:hello@anything.com) if you need to restore data.
  </Accordion>

  <Accordion title="Can I write custom queries?">
    Anything writes queries automatically. For custom queries, use the SQL editor in the database viewer or create a [Function](/apps/backend) and describe what you need.
  </Accordion>

  <Accordion title="I want users to see test data when they log in">
    Ask the agent to add sample data and be specific about what it should look like. [See this video](https://www.loom.com/share/fb688b52623b46d5b8f0a9eefb42d3dc?sid=2a87f3ca-7aef-43fd-827e-68d34a6df54d) for a demo.
  </Accordion>
</AccordionGroup>

## Terminology

Think of a database as a collection of connected spreadsheets.

| Term          | What it means                                   |
| ------------- | ----------------------------------------------- |
| **Table**     | Like a spreadsheet (e.g., "Users", "Products")  |
| **Fields**    | The columns (e.g., "name", "email")             |
| **Rows**      | Individual entries                              |
| **Schema**    | The overall structure of your tables and fields |
| **Query**     | Instructions to get or save data                |
| **Migration** | A change to your database structure             |

You don't need to memorize these. Describe what you want to store and Anything handles the rest.
