Java Devil
Java Devil

Reputation: 10959

How do I convert a Java SQL String to SQL in Datagrip?

I have a statement in my Java code like so

String sql = "SELECT COL1, COL2, COL3, " +
             " COL4, COL5, COL6, COL7 "  +
             " FROM TABLE T";

Is there an easy way to convert/format this as a SQL query (like below) in Datagrip. Similar to what SQLWorkbench does with a "Clean Java Code" by pressing Alt+L?

SELECT COL1, COL2, COL3,
       COL4, COL5, COL6, COL7 
       FROM TABLE T

Upvotes: 3

Views: 3071

Answers (2)

moscas
moscas

Reputation: 10345

  1. Put the caret on the string literal
  2. Press Alt+Enter
  3. Choose Copy string concatenation text to clipboard List item

Upvotes: 2

Vasilii Chernov
Vasilii Chernov

Reputation: 1464

Firstly, you need to inject proper SQL dialect

select dialect

select dialect

select specific dialect

select specific dialect

successful injection

successful injection

and then edit SQL fragment

edit fragment

or call Execute (Ctrl+Enter) from context menu.

Upvotes: 0

Related Questions