How do I pretty format my SQL query in DBeaver?

Albert picture Albert · Sep 26, 2017 · Viewed 41.9k times · Source

I use DBeaver for my main IDE to query multiple databases. When I query a table, it automatically generates a long select statement with all columns in one line.

When I am making more complex queries, this gets very cumbersome to work with and read. I would like to view the select values on separate lines rather than one long string.

Is there an easy way (perhaps by using Notepad++ or Sublime Text) to break up the query (with line breaks after the commas)?

For example,

select name, address, city, state, country, zip_code, birthday, membership_type 
from customers

to

select
name,
address,
city,
state,
country,
zip_code,
birthday,
membership_type
from customers

Answer

Yurii Verbytskyi picture Yurii Verbytskyi · Mar 12, 2019

DBeaver has a shortcut for this purpose. In SQL Editor: enter image description here