Format sql files using the sql-formatter npm package
-
Open VS Code and press F1 or Ctrl + Shift + P to open command palette, select Install Extension and type
lea21st.vscode-sql-formatter
. Or launch VS Code Quick Open (Ctrl + P), paste the following command, and press enter.ext install lea21st.vscode-sql-formatter
"sql-formatter.uppercase": false,
"[sql]": {
"editor.defaultFormatter": "lea21st.vscode-sql-formatter"
}
- sql - [Standard SQL][]
- mariadb - [MariaDB][]
- mysql - [MySQL][]
- postgresql - [PostgreSQL][]
- db2 - [IBM DB2][]
- plsql - [Oracle PL/SQL][]
- n1ql - [Couchbase N1QL][]
- redshift - [Amazon Redshift][]
- spark - [Spark][]
- tsql - [SQL Server Transact-SQL][tsql]
sql-formatter.dialect
: Defaults to "sql" (see the above list of supported dialects)
sql-formatter.uppercase
: Defaults to false (not safe to use when SQL dialect has case-sensitive identifiers)
sql-formatter.linesBetweenQueries
: Number of linebreaks between queries. Defaults to 2.