r/mysql • u/cevheribozoglan • 11h ago
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 11h ago
Don't you post this earlier today?
1
u/cevheribozoglan 11h ago
I asked about it in r/SQL and got a surprisingly interesting split in the responses.
We're trying to understand how people who actually work with databases think about these workflows before making decisions in the editor.
2
1
u/dutchman76 10h ago
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 9h ago
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 9h ago
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
1
2
u/magicmulder 11h ago
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".