The formatter breaks a query onto several lines and uppercases keywords. select id, name from users where active = true and name = 'a b' order by name, with the PostgreSQL dialect, becomes SELECT, a column list, FROM users, a WHERE clause with AND on its own line, and ORDER BY. The boolean becomes TRUE. The string 'a b' keeps the three spaces between a and b.
Dialect is the control that changes quoting and a few keyword spellings. The choices are sql, postgresql, mysql, sqlite, transactsql and bigquery. sql is the generic start. Pick the dialect that matches the engine you will run, especially if you use backticks, square brackets or dollar quotes. The formatter does not connect to a database and does not check that the tables exist.
The minifier is the reverse: one line, same keyword case, strings still untouched. If a quote is missing, both pages will follow the formatter’s parse, which may not be the query you thought you wrote.
Dialect postgresql. select id, name from users where active = true and name = 'a b' order by name
SELECT id, name FROM users WHERE active = TRUE AND name = 'a b' ORDER BY name, broken across lines. The three spaces inside the string stay.
The string is the regression. A formatter that collapses 'a b' to 'a b' has changed the query.
Keywords are uppercased, and in the PostgreSQL dialect true is a keyword. The string 'a b' is not a keyword, so its spaces stay.
sql, postgresql, mysql, sqlite, transactsql and bigquery. Identifier quoting differs. Pick the one you will actually run.
No. It only reprints it. A missing table is not an error here.
The SQL minifier collapses whitespace outside strings, comments and quoted identifiers, and it still uppercases keywords.