Formatting SQL
Only in DbVisualizer Pro
This feature is only available in the DbVisualizer Pro edition.
Formatting puts the clauses of a statement on separate lines and indents them, so that the SQL is easier to read. You choose how SQL is formatted in the formatting settings, and you can keep different settings in profiles, for example one per project.
Formatting statements
The Format SQL submenu, in the SQL Commander main menu and in the editor's right-click menu, contains operations for formatting SQL statements:

- Format Buffer formats all statements in the editor, and Format Current formats the statement at the cursor, or the selected text.
- Copy Formatted copies the selected SQL to the clipboard in formatted form, without changing the text in the editor.
- Paste Formatted formats the SQL on the clipboard and pastes it into the editor. If the SQL is embedded in program code, for example in Java or PHP string literals, select SQL is between and enter the character that encloses the SQL, such as
". DbVisualizer then extracts the SQL from the code before formatting it. - Unformat Buffer and Unformat Current make the statements compact by putting each statement on a single line.
The formatting settings also apply to the Format SQL option in the Script Object dialog, and to editor templates with Format when activated selected.
Formatting settings
To change how SQL is formatted, open Tools → Tool Properties and select the General / SQL Formatting category. The settings are grouped in categories, such as Indentation, Line Breaks and Transformations. For example, to write keywords in lowercase, change Case in the Transformations category.

The Sample tab next to the settings shows how sample SQL is formatted, and it's updated as you change the settings. To try the settings on your own SQL, paste it in the SQL Editor tab and click Format. Click Apply to save your changes.
To keep part of a script unformatted, put it between two line comments, -- FORMAT_OFF and -- FORMAT_ON. You can change these markers in the Input category.
Formatting engine
By default, SQL is formatted by the Standard engine, which formats SQL according to the database type of the connection. For compatibility with earlier versions, you can select the Legacy engine with Formatting Engine in the General category of the settings. It will be phased out in a future version, and some settings are only available for one of the engines.
Formatting profiles
The formatting settings are saved in profiles. You can create several profiles, for example one per team or project, and select the profile to edit in the Profile list. To create, duplicate, rename or delete a profile, use the buttons next to the list.
The profile with Use by Default selected is used for all connections. To use a different profile for a connection, select it in SQL Formatting Profile, in the SQL Editor category of the connection properties.