# Database

> Manage your project's data — create tables, edit rows, set access rules, enable realtime, import/export CSV, and run SQL with AI help.

Source: https://knowledge.estage.com/cloud/database/
Part of the ESTAGE knowledge base (https://knowledge.estage.com). Full corpus: https://knowledge.estage.com/llms-full.txt

---
The **Database** tab is where your project's data lives. The left rail lists your tables; the
main panel shows the selected table's data.

## Browsing and editing data

Select a table to open its **data grid**:

- **Search** across all columns; results are paginated (50 rows per page).
- **Add row** — a form with a field per column (empty = no value; booleans get a
  true/false dropdown).
- **Click a row** to edit it; the trash icon deletes it (with confirmation).
- **Export** — download the table as CSV.
- **Import** — upload a CSV to bulk-load rows.

### Test data in one click

- **Sample data** — the AI generates realistic example rows for the table; you review the
  proposal before it runs.
- **Seed users** — on a user-profile table, creates 5 throwaway test accounts so you can try
  member features without inventing users manually.

## Creating a table

Click **New table**:

1. Name it (lowercase with underscores, e.g. `booking_requests`).
2. Add fields — each with a name, a type (text, number, integer, boolean, uuid, datetime,
   date, json), and an optional flag.
3. Pick **who can access it** (this matters — see below):
   - **Anyone can read** — public content, like posts on a blog feed.
   - **Anyone can read & submit** — public content visitors can add to, like a guestbook.
   - **Each user sees only their own rows** — private per-user data, like saved favorites.
   - **Private** — no public access; only your server functions can touch it.

Every table automatically gets an `id` and a `created_at` column.

## Access rules (Policies)

Access rules decide what your site's visitors can do with each table — they're enforced by
the database itself, so there's no way around them from the browser.

Click **Policies** on a table to manage them:

- See whether row-level security is on, and the list of current rules.
- **Add a policy** from presets: *Anyone can read*, *Logged-in users can read*, *Anyone can
  insert*, *Each user manages only their own rows* — or build a **custom** rule if you know
  SQL.
- Delete rules you no longer want.

:::caution
A table without permissive policies is invisible to your site's visitors — if a feature shows
no data, missing policies are the first thing to check. The AI sets correct policies when it
builds features; this modal is for inspecting and adjusting them.
:::

## Realtime

The **RT** toggle (next to each table in the rail, or the **Realtime** button in the toolbar)
makes a table *live*: pages on your site that subscribe to it update instantly when data
changes — new chat messages appear, counters tick, feeds refresh without reload.

## SQL editor

For anything the UI doesn't cover, open the **SQL editor** (bottom of the table rail):

- Type a query and **Run** — results appear below; write statements (INSERT, UPDATE, CREATE…)
  confirm on success.
- Don't write SQL? Use the **Ask AI to write SQL** bar at the top — describe what you want
  (*"a reviews table anyone can read, with realtime"*) and it generates the statement for you
  to run.
