Database
Run SQL on your app's data
Read and change development rows, or read published data, with one SQL statement at a time in the SQL console.
The SQL console runs one SQL statement against your app's data and shows the answer as a table. Use it on development data to look up, fix or seed rows; on published data it only reads. It is available in every app.
When to use it
- You want to check a row, count records or try a filter faster than clicking through the table view.
- You need to correct or add development rows while you test.
- You want to read what the published app saved, without copying production data into a prompt.
To change tables or columns, ask the build AI instead, because the structure changes only through the app's migrations. See Change saved data safely.
How to use it
- Open Data and choose the Data authority (Development data or Production data) and the data space.
- Select SQL in the toolbar.
- Type one statement in SQL statement, for example
SELECT status, count(*) FROM bookings GROUP BY status. - Select Run (or press Ctrl+Enter, Cmd+Enter on a Mac).
The rows then appear below the statement. Export CSV downloads them; Earlier statements lists your last 20, kept in this browser only.
Development data reads and changes rows. A change refreshes the preview and the table view straight away.
Production data only reads, with SELECT, and only when:
- the data space is on Postgres (moved to Postgres, or your own Postgres); Ahamo's built-in database answers "SQL on published data needs Postgres"; and
- Read production data is on in Settings › AI access. It is off by default, and only people who can publish the app can turn it on.
Every statement on published data is recorded in the activity log with your name, never with its results. Changes to development data are recorded too.
Plans and limits
The console works the same on every plan.
| Limit | Value |
|---|---|
| Statements per run | 1 |
| Statement length | 32 KB |
| Time per statement | 10 seconds |
| Rows in an answer | 500 |
| Size of an answer | 5 MB |
| Size of one value shown | 64 KB on Postgres, 1 MB on development data |
| Who | Can |
|---|---|
| People who can edit the app | Run statements on development data |
| People who can read the app's database | Read published data, when the setting above is on |
Troubleshooting
"Running SQL on development data needs permission to edit the App." Ask a workspace admin for edit access to the app.
"Turn on Read production data…" The app's Read production data setting is off. Someone who can publish the app can turn it on in Settings › AI access.
The statement is refused as a schema change. CREATE, ALTER and DROP are not run here. Describe the
change to the build AI, which writes a migration you can review.
"Showing the first 500 rows…" The answer was cut. Add a WHERE or LIMIT, or select fewer columns.
A message asks you to run a CREATE ROLE or GRANT line. Your own Postgres needs a read-only role for the
console once. People who can publish the app see the line to run in their database; others are asked to fetch
someone who can.