SQL Formatter Options
Options
Select
The SELECT Options in the SQL Formatter Tool allow you to customize the formatting of SELECT statements in SQL queries. These settings control the placement of line breaks and indentation, making your SQL queries more readable and organized.
SELECT Clauses
For each clause, two checkboxes are provided:
- Linebreak Before: Adds a line break before the clause.
- Linebreak After: Adds a line break after the clause.
SELECT
- The main
SELECTclause is always formatted. Options allow you to add line breaks before or after this clause for improved readability.
- The main
INTO
- Configures line breaks around the
INTOclause, commonly used inSELECT INTOstatements.
- Configures line breaks around the
FROM
- Manages line breaks around the
FROMclause, which specifies the source tables or views.
- Manages line breaks around the
JOIN
- Formats
JOINstatements and allows adding line breaks before or after. - Example: Use line breaks to clearly separate join statements in complex queries.
- Formats
Indent JOIN
- Adds indentation to
JOINclauses for better alignment with nested queries.
- Adds indentation to
ON
- Configures line breaks around the
ONclause, used for join conditions.
- Configures line breaks around the
Indent ON
- Adds indentation to
ONclauses, improving readability in queries with multiple conditions.
- Adds indentation to
WHERE
- Adds line breaks before or after the
WHEREclause, which filters records.
- Adds line breaks before or after the
HAVING
- Formats the
HAVINGclause and adds line breaks to separate it from other parts of the query.
- Formats the
GROUP BY
- Configures line breaks around the
GROUP BYclause, used for grouping data.
- Configures line breaks around the
Stack GROUP BY
- Stacks each column in the
GROUP BYclause on a new line for better visibility.
- Stacks each column in the
ORDER BY
- Adds line breaks around the
ORDER BYclause, which sorts query results.
- Adds line breaks around the
Stack ORDER BY
- Stacks each column in the
ORDER BYclause on a new line for better readability.
- Stacks each column in the
UNION 2x
- Ensures a double line break before
UNIONstatements for clear separation of combined queries.
- Ensures a double line break before
Sub-Select / Common Table Expressions (CTEs)
Open „(„
- Adds a line break before or after the opening parenthesis in sub-queries or CTEs.
Close „)“
- Adds a line break before or after the closing parenthesis in sub-queries or CTEs.
Indent SELECT
- Indents
SELECTstatements inside sub-queries or CTEs, enhancing their structure and readability.
- Indents
Compact vs. Expand
- Compact: Produces a concise SQL format by minimizing line breaks.
- Expand: Adds line breaks and indentation to create a more structured and visually clear SQL output.
The Extract & Generate Options in the SQL Formatter Tool provide functionality to extract SQL statements from source code (e.g., Java, C#) and generate source code in various programming languages based on formatted SQL. These features are essential for integrating SQL with application code efficiently.