Write and run SQL
The SQL editor runs statements against the active connection and shows their output in the results grid. You can run one statement, selected text or a complete script.
Write and run SQL
Section titled “Write and run SQL”- Open your connection and select Data in the toolbar.
- Enter a statement in the SQL editor.
- Use the completion suggestions for table names, columns and SQL syntax.
- Choose Query › Format SQL if you want to format the statement.
- Check the active connection and the SQL.
- Click Run.
- Review any query approval prompt before you approve execution.
- Read the returned rows, completion status or database error.

Choose which SQL runs
Section titled “Choose which SQL runs”The run controls change when the editor contains several statements or a text selection.
| Control | SQL that runs |
|---|---|
| Run | The single statement in the editor. |
| Run Current | The statement at the cursor in a script. |
| Run Selection | The selected SQL text. |
| Run All | The complete editor contents. |
Select complete SQL when you use Run Selection. TableAI sends that text for execution; it does not complete a partial statement.
Review a script’s results
Section titled “Review a script’s results”- Click Run All to submit the script.
- Select a statement in the list above the results grid.
- Inspect its rows or status.
- If a statement failed, read its database error and check which later statements did not execute.
Use your database’s transaction syntax when several changes must succeed together. Before you repeat a failed script, check which changes reached the database.
Cancel a running query
Section titled “Cancel a running query”- Click Cancel in the SQL editor.
- Wait for the cancellation result.
- Use Force Stop if normal cancellation does not finish and the button becomes available.
Force Stop terminates the connection and can require reconnection. Check the outcome of interrupted writes before you run them again. For timeout and cancellation checks, see slow or timed-out queries.
Save SQL or find an earlier query
Section titled “Save SQL or find an earlier query”Choose Query › Save Query to keep SQL for reuse. Open Query › Saved Queries to retrieve it.
For executed SQL, open View › Query History. Search the SQL text, then narrow the list by connection, status, time range or source. The default source shows queries you ran; select agent or system queries when you need those records.
Use Query › Open Query in New Tab to work on SQL in a separate tab. The keyboard workflow lists the execution and editing shortcuts.
Related
Section titled “Related”- Read results for filters, values and pagination.
- Diagnose performance to investigate a slow statement.
- Guardrail help if approval prevents execution.
- Database guides: PostgreSQL, MySQL and SQLite.