SQL Formatter 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.

Sql Formatter Options Alignment

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.
  1. SELECT

    • The main SELECT clause is always formatted. Options allow you to add line breaks before or after this clause for improved readability.
  2. INTO

    • Configures line breaks around the INTO clause, commonly used in SELECT INTO statements.
  3. FROM

    • Manages line breaks around the FROM clause, which specifies the source tables or views.
  4. JOIN

    • Formats JOIN statements and allows adding line breaks before or after.
    • Example: Use line breaks to clearly separate join statements in complex queries.
  5. Indent JOIN

    • Adds indentation to JOIN clauses for better alignment with nested queries.
  6. ON

    • Configures line breaks around the ON clause, used for join conditions.
  7. Indent ON

    • Adds indentation to ON clauses, improving readability in queries with multiple conditions.
  8. WHERE

    • Adds line breaks before or after the WHERE clause, which filters records.
  9. HAVING

    • Formats the HAVING clause and adds line breaks to separate it from other parts of the query.
  10. GROUP BY

    • Configures line breaks around the GROUP BY clause, used for grouping data.
  11. Stack GROUP BY

    • Stacks each column in the GROUP BY clause on a new line for better visibility.
  12. ORDER BY

    • Adds line breaks around the ORDER BY clause, which sorts query results.
  13. Stack ORDER BY

    • Stacks each column in the ORDER BY clause on a new line for better readability.
  14. UNION 2x

    • Ensures a double line break before UNION statements for clear separation of combined queries.

Sub-Select / Common Table Expressions (CTEs)

  1. Open „(„

    • Adds a line break before or after the opening parenthesis in sub-queries or CTEs.
  2. Close „)“

    • Adds a line break before or after the closing parenthesis in sub-queries or CTEs.
  3. Indent SELECT

    • Indents SELECT statements inside sub-queries or CTEs, enhancing their structure and readability.

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.