SQL Formatter Options

Alignment

The Alignment Options in the SQL Formatter Tool allow you to control how specific elements of your SQL statements are aligned. These settings improve the readability of your code by aligning tokens and operators consistently.

Sql Formatter Options Alignment

Available Options

  1. Align Comma

    • Ensures that commas in lists (e.g., in SELECT or INSERT statements) are vertically aligned for better readability.
  2. Align Alias

    • Aligns table or column aliases (e.g., AS alias) to a consistent position, making it easier to identify them.
  3. Smart Alignment

    • Automatically determines optimal alignment based on the structure and length of the SQL statement.
    • Overrides manual alignment rules when enabled for a more intelligent and dynamic formatting style.
  4. Align at Position

    • Allows you to set a specific column position (e.g., 60) for alignment.
    • Use the -5 and +5 buttons to fine-tune the alignment position incrementally.
    • This option is disabled if Smart Alignment is enabled.
  5. Align Equal Sign

    • Aligns equal signs (=) in SQL statements, especially in WHERE clauses or assignments, to enhance clarity.
  6. Align Operator

    • Aligns other operators (e.g., +, -, *, /) used in expressions or conditions for consistent formatting.
  7. Align ||

    • Aligns concatenation operators (||) when used in SQL statements, improving the visibility of concatenated strings or expressions.

How to Use These Settings

  1. Enable/Disable Specific Alignments

    • Check or uncheck the boxes for options like Align Comma, Align Equal Sign, or Align || to toggle their alignment features.
  2. Smart Alignment vs. Manual Alignment

    • Enable Smart Alignment for automatic, dynamic alignment based on SQL structure.
    • Disable Smart Alignment to manually set a specific alignment position using the Align at Position option.
  3. Fine-Tune Alignment Position

    • Use the position field and the -5/+5 buttons to adjust alignment positions incrementally.

Tips for Optimal Usage

  • Use Smart Alignment for general-purpose formatting, as it dynamically adapts to the SQL structure.
  • Enable specific alignment options like Align Equal Sign or Align Operator when working with complex conditions or calculations to enhance clarity.
  • Use Align at Position for strict alignment requirements, such as adhering to organizational or team coding standards.