Is there any widely used SQL coding standard out there? SQL is little bit different from C/C++ type of programming languages. Really don't know how to best format it for readability.
SQL is a fourth-generation language, meaning it is a scripting language that does not require compiling to run. Like most fourth-generation languages, SQL requires an interpreter that translates rather than compiles code. As with all languages, SQL has rules for issuing commands and queries.
If the name is the same as an SQL keyword, enclose the name within quotation marks. The name of an object in a database for a table or a column should be unique and not too long. Avoid special characters in the name like $, &, * , etc. (use only letters, numbers, and underscores).
Wouldn't call it coding standard - more like coding style
SELECT     T1.col1,     T1.col2,     T2.col3 FROM     table1 T1     INNER JOIN ON Table2 T2 ON T1.ID = T2.ID WHERE     T1.col1 = 'xxx'     AND T2.Col3 = 'yyy'   I like the comma preceding way:
SELECT       column1     , column2     , column3     , COALESCE(column4,'foo') column4 FROM     tablename WHERE     column1 = 'bar' ORDER BY        column1     , column2   it makes it the easiest to read and debug in my opinion.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With