stratolabs
stratolabs

Reputation: 11

How do I Structure SQL Code like an Formatter to make it readable better by SQL Command to Database

I want to ask a SQL database to get the structured SQL code back of my query.

For example this SQL code:

SELECT customer_id, customer_name. customer_surname, customer_street 
FROM customer 
WHERE customer_name = "%benz%"

should be answered in a query to the SQL database like that:

SELECT 
    customer_id, 
    customer_name, 
    customer_surname, 
    customer_street 
FROM 
    customer 
WHERE 
    customer_name = "%benz%"

Does anybody know how to solve this?

Upvotes: 1

Views: 791

Answers (1)

The Impaler
The Impaler

Reputation: 48810

Just a note since I see no other answers (yet).

You can use a number of editors to format (aka "beautify") your SQL query. For example:

  • I frequently use Squirrel SQL Client where you place the cursor in your query and type Ctrl+Alt+F.
  • Or, you can use one of several Eclipse plugins.
  • Lots of other editors, but haven't seen the database doing the formatting for you.

Upvotes: 1

Related Questions