Ga naar inhoud

Header

Styling conventions

Introduction

Many programming languages use styling conventions: rules for writing code.

This serves the following purposes:

  • Increasing the readability of the code.

  • Easier to make modifications by others.


For SQL, there is no single set of styling conventions.

  • There are different standards.

  • It is highly recommended to follow one standard with your colleagues.




1. Considerations for styling conventions

We consider a number of different choices in standards:




1.1. Indentation

2 spaces

SELECT
  *
FROM
  <table_name>;

Tab

SELECT
    *
FROM
    <table_name>;




1.2. Capitalization

Uppercase

SELECT
  *
FROM
  <table_name>;

Lowercase

select
  *
from
  <table_name>;




1.3. Naming

Snake case

SELECT
  first_name
FROM
  students;

Camel case

SELECT 
  firstName
FROM
  students;




2. Example standards

If you want to delve deeper into standards, take a look at the following pages:




Summary

  • Styling conventions help with:
    • Increasing the readability of your code.
    • Making it easier for others to make modifications.
  • There are different choices in standards for SQL.
    • Choose one standard with your colleagues.