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
SELECT
clause 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
INTO
clause, commonly used inSELECT INTO
statements.
- Configures line breaks around the
FROM
- Manages line breaks around the
FROM
clause, which specifies the source tables or views.
- Manages line breaks around the
JOIN
- Formats
JOIN
statements 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
JOIN
clauses for better alignment with nested queries.
- Adds indentation to
ON
- Configures line breaks around the
ON
clause, used for join conditions.
- Configures line breaks around the
Indent ON
- Adds indentation to
ON
clauses, improving readability in queries with multiple conditions.
- Adds indentation to
WHERE
- Adds line breaks before or after the
WHERE
clause, which filters records.
- Adds line breaks before or after the
HAVING
- Formats the
HAVING
clause and adds line breaks to separate it from other parts of the query.
- Formats the
GROUP BY
- Configures line breaks around the
GROUP BY
clause, used for grouping data.
- Configures line breaks around the
Stack GROUP BY
- Stacks each column in the
GROUP BY
clause on a new line for better visibility.
- Stacks each column in the
ORDER BY
- Adds line breaks around the
ORDER BY
clause, which sorts query results.
- Adds line breaks around the
Stack ORDER BY
- Stacks each column in the
ORDER BY
clause on a new line for better readability.
- Stacks each column in the
UNION 2x
- Ensures a double line break before
UNION
statements 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
SELECT
statements 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.