FORMAT

Core command

Reformats the current SQL for readability without changing its meaning

Arguments

None.

Examples

select a.id,a.name from customer a where a.status='ACTIVE';
FORMAT;
//

Notes

FORMAT; - explicitly reformats the current SQL for readability (see docs/SPRINT_0912A_EXPAND_FORMAT_SQL_ERRORS.md, section 5).

This is a transformation, not an execution command: it never runs the current SQL, only reflows it. On success, the formatted SQL becomes the current SQL - ///SHOW QUERY display it and / reruns it. On failure (the SQL cannot be tokenized safely - an unterminated string literal, quoted identifier or comment), the current SQL is left byte-for-byte unchanged and a concise reason is printed.

FORMAT; only ever changes whitespace and line breaks between tokens - it never rewrites, reorders or drops the text of a string literal, comment (Oracle hints included), quoted identifier, number or keyword, so it cannot change what the statement means. See SqlFormatterService for why that guarantee holds unconditionally, and why no external formatter library or regex-based approach was used.

Last modified in release 5.2.0.