21

In MySQL Workbench, one can use the keyboard shortcut Ctrl + ENTER to execute the statement at cursor (delineated with semi colons).

Is there a similar shortcut in pgAdmin?


For SQL queries that span on only one line, I use a voice command in Dragon NaturallySpeaking:

Sub Main
    SendKeys "{End}"
    Wait(0.3)
    SendKeys "+{Home}"
    Wait(0.3)
    SendKeys "{F5}"
End Sub

enter image description here

but I don't have any solution for SQL queries that span although more than one line.

Franck Dernoncourt
  • 2,083
  • 11
  • 33
  • 52
  • 1
    One of the most common tasks I do at work is check for postal codes that are entered in the correct format but are wrong. I need to group all cities and postal codes together, with counts of each. From the results, I then start selecting each of the employees - and then manually verifying the postal code .. then issuing an update statement. Its a manual process that can't be automated - but having to highlight before execute makes it insanely burdensome. Maybe I will suggest an improvement for pgadmin. – DHW Jul 06 '16 at 22:11
  • @DHW I filed a feature request: https://redmine.postgresql.org/issues/1439 – Franck Dernoncourt Jul 06 '16 at 22:37
  • 2
    2023 and this handy feature is still missing. Disappointing. – Rafs May 02 '23 at 15:01

2 Answers2

8

Since there seems to be no way to define such a keyboard shortcut, I filed a feature request: https://redmine.postgresql.org/issues/1439 , which got rejected:

​Issue #1439 has been updated by Dave Page.

Status changed from New to Rejected

We follow the pgAdmin 3 behaviour in this regard - when you execute a query (or explain etc), if any text is selected, only that text is executed. If nothing is selected, the entire query (or set of queries) are executed.

Since amazingly with pgAdmin one has to login to view issues / feature request, here is a screenshot:

enter image description here

Franck Dernoncourt
  • 2,083
  • 11
  • 33
  • 52
  • Great! I was going through the pgadmin source to see if I could make the change and submit a proposed patch but I think its beyond my level at the moment. – DHW Jul 07 '16 at 04:03
  • @DHW Feature request got rejected :( – Franck Dernoncourt Jul 07 '16 at 20:31
  • 2
    I saw that. First of all, the Control+Shift+E is in reference to the current pgadmin 4 which is in beta. Second of all, it doesn't execute the current statement, it has the same behaviour as before - just a lot slower in this version. Disappointing when things get a knee-jerk reaction without any thought. – DHW Jul 08 '16 at 12:26
  • @DHW they didn't seem overly excited at the idea indeed… – Franck Dernoncourt Jul 08 '16 at 15:32
  • 3
    The whole point in having a keyboard shortcut is to avoid needing to use the mouse, which is required in order to select the text of the query to execute. It's too bad the pgAdmin devs are unwilling to have this useful feature. It shouldn't be too hard to detect which query is "selected" based on cursor position in the file. – axiopisty Oct 30 '18 at 17:58
  • you may need to reopen the request. It seems the support member thought there is a shortcut and rejected. – DDphp Sep 24 '20 at 12:08
  • 2
    I love this : “We follow the pgAdmin 3 behaviour in this regard”. For the most part pgAdmin4 is inferior to pgAdmin3, but when it comes to suggesting a useful improvement, no, pgAdmin3’s fine … – Manngo Aug 06 '22 at 06:01
  • This UX design is so poorly considered I'm now looking for a different GUI tool for PostgreSQL. – Robert May 29 '23 at 16:11
5

You can select your query in pgAdmin sql window and press F5. Same will work if you just put cursor on any line in your statement without actually selecting it but only if your statements are separated with semicolon.

Dimon Buzz
  • 151
  • 2