Code Style Guide: SQL

unruthless edited this page Sep 13, 2010 · 5 revisions

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.

Correct:
SELECT * FROM table;

Incorrect:
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.

Correct:
SELECT n.name AS myname FROM names AS n;

Incorrect:
SELECT n.name myname FROM names n;

Clone this wiki locally
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.