r/mysql • u/cevheribozoglan • Sep 11 '26
discussion How should a SQL editor handle multiple statements when you click "Run"?
We're building **LibreDB Studio**, an open-source SQL editor, and one of our volunteer contributors raised an interesting question about how multiple SQL statements should behave when using the Run action.
We're trying to understand the actual habits and expectations of SQL users before making a decision, so I'd really like to hear how you use SQL editors in practice.
For example:
CREATE TABLE test (...);
INSERT INTO test VALUES (...);
SELECT * FROM test;
What would you expect when you click **Run**?
Some possible approaches:
- **Run all statements*** `Run` executes everything in the editor.* `Run Selection` can be used when you only want part of it.
- **Run the current statement*** `Run` executes the statement where the cursor is.* `Run All` executes the whole editor.
- **Selection takes priority*** No selection : current statement* Selection : selected statements* `Run All` is available separately.
- Other :)
there are also some interesting edge cases around this, especially when multiple statements are involved: should they run in a transaction by default, or should transaction handling always be explicit?
DBeaver, DataGrip, SSMS, pgAdmin, TablePlus, Toad, PL/SQL Dev, phpMyAdmin, etc. what behavior feels most natural to you? And what behavior are you already used to?
We're continuing the discussion on GitHub as well, if you'd like to see the original question or add to the discussion:
1
u/Imaginary__Bar Sep 11 '26
Don't you post this earlier today?
3
u/magicmulder Sep 11 '26
TOAD uses different "run" modes - Shift-F9 runs the statement at cursor, F5 runs all statements etc.
If the question is what should be the default, I would say "all".
1
u/navicat-gu 25d ago
jomofo's "script mode vs scratchpad mode" split matches how I actually work, and I'd design around that rather than picking one universal default.
What feels natural day to day
CREATE+INSERT+SELECTis fine auto-committed statement by statement for exploration; a migration script should be an explicit transaction the user wrote.Configurable default is fine, but the safe out-of-the-box behavior is "current statement," with Run All one click further away. Power users who want "F5 = everything" will find the setting in thirty seconds; beginners won't recover a
DROPthey didn't mean to send.Edge cases worth deciding up front:
;— still run it.SELECTandINSERTin one Run All — show each result set / affected-row count, don't only keep the last one.Disclosure: I'm RC, Director of Digital Strategy @ Navicat. In Navicat 18, Run executes the current statement (or the selection); running the whole editor is a separate action. That matches the "scratchpad-safe" habit above. Take it as one data point among the tools you're already surveying.
1
u/dutchman76 Sep 11 '26
My personal typical work is one command at the time, i type it hit enter, get result, no errors, move on to the next one.
when I run a whole sequence like that, it's probably a copy & paste from somewhere else, and I wouldn't be waiting for output from each command, so I'd paste and run the whole thing in one shot.
1
u/jomofo Sep 11 '26 •
I see it as two different modes. I'll call them "script mode" and "scratchpad mode". If I'm in "script mode" I'm expecting them to run sequentially and perhaps optionally in a single transaction. If I'm in "scratchpad mode" I'm likely troubleshooting something and running several disparate queries that I want to control one-by-one and likely don't want to accidentally execute them all sequentially.
1
u/roXplosion Sep 11 '26
I'd have two buttons; "Run" (runs everything), and "Run Selected" (runs only statements where any part is selected, or the single statement where the cursor is if nothing is explicitly selected).
1
u/SaltineAmerican_1970 Sep 11 '26
Ask me when I click the run button. Allow me to not be asked again.
1
u/Standgrounding Sep 12 '26
Run selection > run all
1
u/SurgioClemente Sep 11 '26
Copy how datagrip does it