Oracle SQL and PL/SQL Coding Guidelines
Coding standards are important because they reduce the cost of maintenance. To enable database developers on the same team to read one another’s code more easily, and to have consistency in the code produced and to be maintained, I have prepared a set of coding conventions for Oracle SQL and PL/SQL. These are by no means the be-all and end-all of Oracle Database standards, and in some instances you may not agree with the conventions I have proposed. That’s why I have created an easy-to-share, easy-to-edit Markdown document with these guidelines, including a snazzy CSS3 style sheet, in my Bitbucket repository. You can adapt these guidelines for your organization’s needs as you see fit; an attribution would be grand but I won’t sue you if you’re dishonest.
Why Markdown? Markdown is easy to read in its original form, can be converted to many different formats, for instance with John MacFarlane’s amazing Pandoc, and – perhaps more importantly – it can easily be integrated in the source code repository and build processes of the database development team, so that everyone has immediate access to it at all times.
In the same folder on my public repository you will find the necessary documents to create a simple and – if I may say so myself – stylish HTML file with menus. Once you’ve installed Pandoc you can create these files by using the commands shown below.
If you happen to be on Ubuntu or a similar Linux distribution you do not even have to search for Pandoc online:
sudo apt-get -y install pandoc
Life does not get much easier than that!
A simple black-and-white HTML file with section numbers:
pandoc -s -S --toc --toc-depth=2 -N -t html5 --highlight-style pygments -A "guidelines footer.html" -o "guidelines.html" "guidelines.md"
A prettified HTML file based on my own style sheet:
pandoc -s -S --toc --toc-depth=2 -t html5 --highlight-style pygments -c "guidelines style.css" -A "guidelines footer.html" -o "guidelines.html" "guidelines.md"
My guidelines have been inspired by similar guidelines such as Steven Feuerstein’s Ideas for Oracle PL/SQL Naming Conventions and Coding Standards, TopCoder’s Oracle PL/SQL Coding Guidelines, and Jonathan Ingram’s SQL and PL/SQL Coding Standards.