Skip to content

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.

  1. Open your connection and select Data in the toolbar.
  2. Enter a statement in the SQL editor.
  3. Use the completion suggestions for table names, columns and SQL syntax.
  4. Choose Query › Format SQL if you want to format the statement.
  5. Check the active connection and the SQL.
  6. Click Run.
  7. Review any query approval prompt before you approve execution.
  8. Read the returned rows, completion status or database error.
SQL editor with a SELECT statement, Run button and returned rows

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.

  1. Click Run All to submit the script.
  2. Select a statement in the list above the results grid.
  3. Inspect its rows or status.
  4. 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.

  1. Click Cancel in the SQL editor.
  2. Wait for the cancellation result.
  3. 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.

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.