SQL naming conventions

• Don't use (ANSI) SQL / MySQL / PostgreSQL / MS SQL Server / ... Reserved Words for column and/or table names. Even if this may work with your (MySQL) installation, it may not with others or with other databases. Some references:

o (ANSI) SQL Reserved Words O MySQL Reserved Words: 4.x, 3.23.x, 3.21.x o PostgreSQL Reserved Words O MS SQL Server Reserved Words

Some commonly misused keywords: TIMESTAMP, TYPE, TYPES, MODULE, DATA,

See also [bug] SQL Reserved Words.

• Capitalization, Indentation o UPPERCASE reserved words O lowercase (or Capitalize) table names O lowercase column names

Example:

SELECT r.rid, p.perm FROM {role} r

LEFT JOIN {permission} p ON r.rid = p.rid — may be on one line with prev. ORDER BY name

Was this article helpful?

0 0

Post a comment