SQL Formatter Options
Options
Lists
The SQL Lists settings in the SQL Formatter Tool allow you to define how lists (such as column names, values, or expressions) are formatted in your SQL statements. These options help improve readability and align the output with your desired style or organizational standards.
Columns/Line
- Specifies the number of columns or list items to display per line in the formatted SQL output.
- Default value:
1
(each item appears on its own line). - Use this to control the vertical spacing of items in lists.
Example with 1
column per line:
SELECT
column1,
column2,
column3
FROM table;
Example with 2
columns per line:
SELECT
column1, column2,
column3
FROM table;
Comma Placement
- Before Comma: Places the comma at the beginning of the next line when wrapping the list.
- After Comma (default): Places the comma at the end of the current line before the line break.
Example: Before Comma:
SELECT
column1
, column2
, column3
FROM table;
Example: After Comma:
SELECT
column1,
column2,
column3
FROM table;
Double Pipe Placement (||
)
- Before
||
: Aligns concatenation operators (||
) at the start of the line when wrapping. - After
||
: Keeps the concatenation operator at the end of the line before the line break.
How to Use These Settings
- Set Columns/Line: Use the dropdown menu to select the desired number of items to display per line.
- Choose Comma or
||
Placement:- Select or deselect the checkboxes to enable or disable specific placement styles.
- The formatter will adjust the output based on your selections.
Tips for Optimal Usage
- Use Single Columns for Clarity: When working with long lists, setting
Columns/Line
to1
improves readability, especially forSELECT
statements orVALUES
clauses. - Choose Consistent Comma Placement: Align with team or organizational preferences (e.g.,
After Comma
is common for readability). - Optimize for Concatenation (
||
): UseBefore ||
for better alignment in long concatenated strings or expressions.