SQL Editor Pro
The SQL Editor runs your own queries against the database that is open in the DevDb panel. It works with every engine that DevDb supports, except Redis and Valkey. For Redis and Valkey, use the RESP console.
Open the editor
- Connect to a database in the DevDb panel.
- In the toolbar at the top of the panel, click SQL Editor. You can also run the command DevDb: Open SQL Editor.
The editor opens as a pane above the table grid. Drag the line between the editor and the grid to change their heights. Double-click the line to set the default height. DevDb keeps the height for each connection.
To give all of the main area to the editor, click the expand button in the bar below the editor. Click it again to go back. When a query returns rows, the grid shows again.
To close the editor, click SQL Editor in the toolbar again, or click the close button in the bar below the editor. Your query tabs stay open.
Without a Pro license, the button shows a PRO lock. Click it to see how to get DevDb Pro.
Write a query
The editor highlights the syntax of your engine: MySQL, PostgreSQL, SQLite, SQL Server, DuckDB, ClickHouse, Cloudflare D1 and Turso. It completes table names and column names from your schema.
| Engine | Query language |
|---|---|
| MongoDB | JSON, for example { "collection": "users", "operation": "find", "query": {} } |
| DynamoDB | PartiQL, for example SELECT * FROM "users" |
| All other engines | SQL of that engine |
Run a query
| Keys | Action |
|---|---|
| Cmd+Enter (macOS) or Ctrl+Enter | Runs the selected text. If you select no text, runs the statement at the cursor. |
| Shift+Cmd+Enter or Shift+Ctrl+Enter | Runs all statements in the editor. |
| Esc | Cancels the query that runs. |
You can also use the Run and Run all buttons. While a query runs, the editor shows the time since it started and a Cancel button.
When you run more than one statement, DevDb runs them in sequence. It stops at the first error.
Query tabs
A query that returns rows opens a tab in the main tab bar, next to your table tabs. The tabs have the names Query 1, Query 2 and so on, and a </> icon. The grid looks the same as for a table: the same fonts, the same column filters and the same pages. Column types show when the engine gives them (for example PostgreSQL and DuckDB).
- Run again: the next query replaces the rows in the query tab. It does not open a new tab.
- Pin: click the pin button on a tab to keep it. The next query then opens a new tab.
- Run all: each statement that returns rows opens its own tab.
- Refresh: click the refresh button on a query tab to run its query again.
- Close: click the x on the tab, as for a table tab.
Query tabs are read-only. You cannot edit cells, delete rows or add rows in a query tab. To change data, run an UPDATE, INSERT or DELETE statement.
Rows, filters and pages
- DevDb loads the first 1,000 rows of a result. When there are more rows, the footer shows a note, for example 5,000 rows (first 1,000). Add
LIMITor aWHEREclause to see other rows. - Type in a column filter to show only the rows that contain the text in that column. The filter ignores case and applies to the loaded rows.
- Use the pages and Show … at once in the footer, as for a table.
- The footer shows the duration of the query.
- Click Copy CSV or Copy JSON to copy all rows that match the filters.
Status line
The bar below the editor shows the result of the last run:
| Result | Example |
|---|---|
| Rows | 5 rows · 12 ms. The rows show in a query tab. |
| Write | 3 rows affected · 12 ms. No tab opens. |
Statement without rows (for example CREATE TABLE) | Done · 4 ms |
| Error | The message from the database, with a red icon. Click Details to see all of the message. |
| Cancel | Query cancelled after 1.40 s |
Writes need your confirmation
Reads run at once, in the read-only mode of the engine. Before a write runs, DevDb shows a dialog with the type of statement and the table that it changes. Nothing runs until you click the run button in the dialog.
An UPDATE or DELETE without a WHERE clause shows this warning:
No WHERE clause: this changes every row.
The extension also checks your confirmation before it runs a write. After a write, DevDb reloads the open table if the write changed it. After CREATE, DROP, ALTER or RENAME, DevDb reloads the table list.
History
Click the clock button in the bar below the editor to see the last 50 queries for the connection. Click a query to put it back in the editor. DevDb keeps the history, the text in the editor and the editor height after you close VS Code.