Why uppercase SQL is so common, and why it doesn't make sense

Why uppercase SQL is so common, and why it doesn't make sense

SQL, or Structured Query Language, is a widely used language for interacting with databases. SQL allows you to create, manipulate, and query data in a structured and efficient way.




A few months ago I joined a project where a codebase was a mix of uppercase and lowercase SQL. I created a migration file and one comment during code review was "It would be better if this was uppercase, as it's good practice to do so". That gave me some mixed feelings - it's not like they followed any standard either.

Most of my previous teams and projects used lowercase SQL. Back when I studied at university or looked at SQL code samples online, a lot of times it's presented in uppercase. I started to wonder why. Is it actually "good practice"? Is it because we were just taught that way, or are there other reasons?

So I went on a research rabbithole. It all comes down to history.

Why Web3 is a Scam and a Fad
Web3 is the latest buzzword in the tech industry, promising to revolutionize the internet by creating a decentralized, peer-to-peer, and trustless network of applications and services. Web3 enthusiasts claim that this new paradigm will empower users, foster innovation, and challenge the dominance of big tech companies. Or so they claim.
Everything you need to know about caching in Java & Spring Boot (plus Redis)
Caching is a technique of storing frequently used data in a fast and accessible memory, such as RAM, to reduce the latency and cost of retrieving it from a slower and more expensive source, such as a database or a network. Caching can improve the performance, scalability, and reliability of

How uppercase SQL came to be

If you look at most SQL tutorials, books, or documentation, you will notice that the SQL keywords are usually written in uppercase.

This convention has a historical reason: back in the days when SQL was first developed, most computer systems used monospaced fonts and no syntax highlighting. This made it hard to distinguish between SQL keywords and other identifiers, such as table names, column names, or variables. To solve this problem, developers adopted the practice of writing SQL keywords in uppercase, so that they would stand out from the rest of the code.

Another major reason for using uppercase SQL keywords is that.. SQL is old.

SQL dates back to 1974. At that time, many keyboards only had uppercase letters, so the language documentation used them as well. This was a common practice in the early days of computing.

You can see how not having lowercase letters in early keyboards also influenced other programming languages, where uppercase syntax is overwhelmingly common - namely COBOL, Basic and Fortran

Stick to lowercase

However, times have changed, and so have the tools that we use to write and execute SQL. Nowadays, most modern editors and IDEs support proportional fonts and syntax highlighting, which make it much easier to read and write SQL code.

In fact, using uppercase SQL keywords can have some drawbacks, such as:

  • It is harder to read: Studies have shown that lowercase text is easier to read than uppercase text, because lowercase letters have more distinctive shapes and patterns, while uppercase letters are more uniform and similar. This means that using uppercase SQL keywords can make your code less readable and more prone to errors.
  • It is harder to type: Typing uppercase letters requires more keystrokes and more effort than typing lowercase letters, especially if you use a keyboard layout that requires you to press the Shift key or the Caps Lock key to switch between cases. This can slow down your typing speed and increase your fatigue. Rest that pinky!
  • It is harder to maintain: If you use uppercase SQL keywords, you have to be consistent and use them throughout your code, otherwise your code will look messy and unprofessional. However, this can be tedious and error-prone, especially if you have to edit or refactor your code later. You may forget to change the case of some keywords, or introduce typos or inconsistencies. However, keep in mind that this goes both ways. It is, however, just easier to lowercase everything - let your editor handle the indentation and syntax highlightning for you.
  • There’s no difference from a technical point of view. Your queries are the same speed in either case.

Many developers on Stackoverflow also do not endorse the use of uppercase syntax, and bring out some pretty great points.

Of course - if your codebase already has a set standard and actually enforces uppercase, then please do use it. I'm giving my pinky a break though.

11 Things You Can Do to Secure Your Linux Server
Linux is one of the most popular and widely used operating systems in the world, especially for servers. Linux servers power millions of websites, applications, databases, and other services that we use every day. However, Linux servers are not immune to cyberattacks, and they require proper security measures to protect

The Bottom Line

In conclusion, the case of your SQL keywords doesn't really matter that much, because SQL is a case-insensitive language, meaning that it treats uppercase and lowercase letters as equivalent.

However, using lowercase SQL keywords can make your code more readable, more writable, and more maintainable, and improve your overall coding experience.

Therefore, I recommend that you use lowercase SQL keywords in your SQL code, and enjoy the benefits of this simple but effective practice.

Why do Linux users often prefer Thinkpads?
Readers like you help support Wirekat. If you purchase using links here, we may earn an affiliate commission. Read more If you are looking for a laptop that can run Linux flawlessly, you might want to consider a Thinkpad. Thinkpads are laptops that have been produced by IBM and Lenovo
How a zero can change everything in Java (a puzzler)
Java is a popular and widely used programming language, but it also has some quirks and surprises that can puzzle even experienced developers. In this blog post, we will explore one such puzzler: what does the following code print? public class Puzzler { public static void main(String[] args) { int x
What can you do on Linux that you can’t do on Windows?
Linux and Windows are two of the most popular operating systems in the world, but they have some significant differences in terms of features, flexibility, and usability. In this blog post, we will explore some of the things you can do on Linux that you can’t do on Windows,
Beginner’s guide to the Linux terminal. Everything you need to know in under 8 minutes of your time
Linux is an open-source operating system that powers many servers, supercomputers, and devices. Learning Linux can boost your career as a software developer, system administrator, cybersecurity professional, or IT support specialist. In this blog post, I will introduce one of the most useful skills you need to master in Linux: