Database Manual · Chapter 4

Database Studio — Validating with the SQL · Data Tabs

Before writing script code, we recommend checking the connection and the data directly on two tabs of Database Studio. Run the SQL in the studio first, confirm the result, and then move it into the script.

xscript
Solution Explorer
├── Data Editor Pages
└── Database
    ├── Database Connections       (Chapter 2)
    ├── Database Studio            ← this chapter
    │   ├── Structure tab          (Chapter 3 — table structure editing)
    │   ├── Data tab               (row view — read-only)
    │   └── SQL tab                (free SQL execution)
    └── Database Events            (Chapter 8)

Choose local in Connection at the top and press [Open]; ● OPEN appears on the right and the table list appears in Tables on the left. [Close] · [Refresh] close the connection or reread the lists, and [Backup...] backs up the open DB to a file (Chapter 9).

Note The studio's connection is the same connection as DB["local"] in scripts. A connection you open stays open after you leave the screen, so while it is open in the studio, DB["local"].IsOpen in scripts is also true.

SQL Tab — Free Execution

Database Studio — SQL tab
Database Studio — SQL tab

An SQL editor with syntax highlighting.

ButtonAction
Run (F5)Runs all SQL in the editor
Run SelectedRuns only the selection (everything if nothing is selected)
ExplainShows the execution plan
Clear · Load .sql... · Save .sql...Clear the editor · read / save a .sql file
HistoryThe last 20 SQL statements run

Caution The button name includes F5, but F5 is the QMachineStudio-wide shortcut for switching to the machine screen (Run) in the development screen. Run SQL by pressing the [Run (F5)] button.

Useful SQL to try with the sample project:

sql
-- Total row count
SELECT COUNT(*) FROM order_history;
 
-- Latest 5 jobs
SELECT id, order_no, menu_name, result, end_time
FROM   order_history
ORDER  BY id DESC
LIMIT  5;
 
-- Count by result
SELECT result, COUNT(*) AS cnt
FROM   order_history
GROUP  BY result;
 
-- Errors only
SELECT id, order_no, menu_name, weight_g
FROM   order_history
WHERE  is_error = 1;

RunSqlSelect / RunSqlScalarInt in scripts take SQL that works on this tab as is. Get into the habit of moving only SQL that passed here into scripts and debugging time drops sharply.

Result Area

AreaContent
Result tableSELECT result rows — column names and values
Status messageN row(s) returned. (ms ms) for SELECT, N row(s) affected. (ms ms) for other commands (INSERT / UPDATE / DELETE etc.)
Execution timeCheck the response time from (ms ms) in the message above

Data Tab — Row View (Read-only)

Shows the rows of the table selected in Tables on the left as a grid. This tab is read-only; narrow the rows with the fields below.

  • WHERE — filter condition (e.g. is_error = 1). Empty = all rows
  • Page Size — maximum number of rows to read at once (default 100)
  • [Load] — rereads the rows with the conditions above and shows them

The bottom of the tab shows the note "(Data editing is read-only in this version. Use SQL tab for INSERT/UPDATE/DELETE.)". Run every INSERT / UPDATE / DELETE on the SQL tab.

Recommended uses of this tab:

  • Quickly check only the rows that match a WHERE filter
  • Visually confirm that a script result (e.g. after DB_UpdateSelected) actually reached the DB
  • Check whether a table is empty or whether data has arrived
  1. In Database Connections, check that local is registered and that [Test Connection] passes (Chapter 2)
  2. In Database Studio, [Open] local and check that order_history appears in Tables on the left (Chapter 3)
  3. On the Data tab, read the current rows with [Load] (filter with WHERE if needed)
  4. On the SQL tab, run the 4 queries above and check the results
  5. If the table is empty, run the following SQL on the SQL tab to add one row
sql
INSERT INTO order_history(order_no, menu_name, start_time, end_time, weight_g, result, is_error)
VALUES('O0001', 'Americano', '2026-01-01 09:00:00', '2026-01-01 09:00:30', 250, 'Done', 0);

Once these five steps are done, it is the script's turn.

Subscribe