Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to autoformat / beautify SQL queries using pgAdmin4?

I would like to autoformat / beautify my SQL-queries directly in pgAdmin4. I know this feature from Java-developing in Eclipse, where I can beautify the whole code using a simple shortcut.

I only found a command line solution so far that makes my SQL queries pretty: pgFormatter.

like image 964
coding_bird Avatar asked Jun 03 '17 15:06

coding_bird


People also ask

How do you enable autocomplete in pgAdmin 4?

Added option to trigger autocomplete on key press in the query tool. This feature allows autocomplete to be accessed with a key press in the query tool. One new parameter is added to Preferences -> Query Tool -> Auto completion -> 'Autocomplete on key press' to disable it.

How do you use the query editor in pgAdmin 4?

The Query Tool is a powerful, feature-rich environment that allows you to execute arbitrary SQL commands and review the result set. You can access the Query Tool via the Query Tool menu option on the browser tree tools menu or through the context menu of selected nodes of the browser tree control.

How do I enable Intellisense on pgAdmin?

I recently discovered in PGAdmin III that you can autocomplete/activate intellisense by hitting Ctrl+Space.

How do I write a SQL query in pgAdmin 4?

The SQL Editor Panel¶ For example, type “SELECT * FROM” (without quotes, but with a trailing space), and then press the Control+Space key combination to select from a popup menu of autocomplete options. After entering a query, select the Execute/Refresh icon from the toolbar.


4 Answers

Try the following command:

shift+Ctrl+k
like image 112
Amazigh Avatar answered Oct 19 '22 07:10

Amazigh


Currently this feature is not implemented in pgadmin4 which does autoformat or beautify SQL-queries automatically but you can expect this feature in near future version as developers are working on this feature.

Developers discussion mail thread for the feature: https://www.postgresql.org/message-id/CAPG3WN46pgzxKERPpr4TSpVFtyeMhParjvKAUzXWOuwZ4qJPhg@mail.gmail.com

like image 42
Murtuza Z Avatar answered Oct 19 '22 06:10

Murtuza Z


In pgAdmin5 on macOS this can be done using Shift + Cmd + K.

Here is where you can find it in the UI: Screenshot

like image 7
SamB Avatar answered Oct 19 '22 07:10

SamB


Still not implemented afaict, but an option would be to use some online tool.

I've successfully used: https://sqlformat.org/

like image 4
estani Avatar answered Oct 19 '22 07:10

estani