Code Style Guide: SQL

unruthless edited this page Sep 13, 2010 · 5 revisions
Clone this wiki locally

This is the Code Style guide for SQL. See the main Code Style Guide page for other languages.

SQL statements should have SQL keywords in ALL CAPS.

SELECT * FROM table;

select * from table;

Never use backticks.

If you find that backticks are needed, that indicates that there is a design problem somewhere. Rather than use backticks, try to fix the design problem.

When specifying an alias for a column or table name, always use the AS keyword.

SELECT AS myname FROM names AS n;

SELECT myname FROM names n;