Skip to content

SQL conventions

Formatting

Tip

IntelliJ can do this for you. Import the IntelliJ formatter settings.

Use lowercase for keywords, aliases, function names, and columns, and table names.

Wrap at 120 characters and do not align horizontally. Multiline statements should follow this indentation format:

select
    pet.name as name,
    pet.age as age,
    owner.name as owner
from
    pet
    inner join species on pet.species = species.id
    left join owner on pet.owner = owner.id
where
    owner.name = 'Berk'
    and species.name like 'Canis%'
;