SQL editor
Database › SQL editor runs SQL against the project database with an editor that knows Postgres.
Run a query
Type SQL and select Run, or press ⌘/Ctrl+Enter to run the selection (or everything). Results appear in a grid with the row count and duration.
select department, count(*) as requests, sum(amount) as total
from purchase_requests
group by department
order by total desc;
How queries run
| Behaviour | Detail |
|---|---|
| Role | The project's owner role, so row-level security doesn't filter results |
| Transaction | All statements run in one transaction |
| Timeout | 15 seconds by default (set by the installation); a query that runs longer is cancelled with SQL_TIMEOUT |
| Rows shown | The first 1,000 rows; the result says when it was truncated |
| Read-only | Tick Read-only to run in a read-only transaction: writes fail with READ_ONLY |
People with read-only access (for example Auditors) always run read-only.
Saved snippets
Select Save and give the query a name. Saved snippets lists your snippets for this project. Snippets are personal.
Error codes
| Code | Meaning |
|---|---|
SQL_TIMEOUT | The query ran longer than the statement timeout |
READ_ONLY | A write in read-only mode |
PERMISSION_DENIED | Postgres refused the operation |
SQL_ERROR | Any other Postgres error, with its message |
From an agent or the API
- MCP:
run_sql(with aread_onlyoption) anddescribe_schema. - API:
POST /api/projects/:name/db/sqlwith{ "sql": "...", "readOnly": true }.
Every query run from the Studio, MCP or the API is audited.
tip
To test what a particular person would see, query as tc_user from server code with tc.db.asUser(req).sql, or check the policies in Database › Policies.
Was this page helpful?