Difference between revisions of "Well Formed SQL Statements"

From database24
Jump to navigation Jump to search
(Created page with '== General == SQL statements can be read much easier, if they are well-formatted. Good formatting is achieved as follows: * align the SQL keywords to the right * make use of fi...')
 
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
 +
[[Category:Conventions]]
 +
[[Category:SQL]]
 
== General ==
 
== General ==
 
SQL statements can be read much easier, if they are well-formatted.
 
SQL statements can be read much easier, if they are well-formatted.
Line 10: Line 12:
 
* align values to the left
 
* align values to the left
  
== Examples ==
 
  
=== SELECT ===
+
== SELECT ==
  
=== INSERT ===
+
=== ORDER BY ===
 +
=== GROUP BY ===
  
=== UPDATE ===
+
== INSERT ==
  
=== DELETE ===
+
== UPDATE ==
 +
 
 +
== DELETE ==
 +
 
 +
== JOIN ==
 +
 
 +
=== Sub SELECT ===

Latest revision as of 15:50, 15 July 2010

General

SQL statements can be read much easier, if they are well-formatted.

Good formatting is achieved as follows:

  • align the SQL keywords to the right
  • make use of field and table aliases
  • use only one field per line
  • align operators to the right
  • align values to the left


SELECT

ORDER BY

GROUP BY

INSERT

UPDATE

DELETE

JOIN

Sub SELECT