programming keyboard case sensitivity for sql

Is SQL Case Sensitive?

We hope you love the products we recommend! Just so you know, when you buy through links on our site, we may earn an affiliate commission. This adds no cost to our readers, for more information read our earnings disclosure.

Find out about the case sensitivity of SQL syntax and learn about naming conventions.

Whether you’ve been working with SQL for years, or are entirely new to SQL, then you surely have noticed that some SQL statements are often written in caps.

If you’re wondering what is that all about and if SQL is case sensitive, you’re in the right place. 

Is SQL case sensitive?

No, by default, SQL is not case-sensitive.

Whenever you see capitalized letters in SQL queries it’s because of a naming convention. Your query would run just the same even if you write your SQL keywords in all caps or not. 

The naming convention states that whenever we write a SQL keyword (identifiers and reserved words) we need to uppercase them. 

SQL Keywords and Conventions

What are SQL keywords?

SQL keywords are reserved words for SQL, a few examples being:

  • SELECT
  • FROM
  • WHERE
  • CASE
  • IN
  • JOIN
  • and more

See here the full list of SQL Reserved Words

What are conventions?

In programming, conventions are a set of guidelines that recommends specific styles, formatting, or specific naming practices, in order to improve the readability of your code.

This helps programmers understand easier each other’s code, keeps their code clean and well-structured – contributing to error reduction. 

Let’s take this query that selects only vegan ingredients from a recipes table:

SELECT ingredient

FROM recipes

WHERE type = ‘vegan’;

Because in SQL, keywords are not case-sensitive, the same query can be written as:

sEleCt ingredient

FroM recipes

wHErE type = ‘vegan’;

Even though both of the queries will provide the same result, the first example is a better choice because it looks clean, well-packaged, it’s easy to understand, and it looks professional. 

Important mention

Some setups give you the custom option to enable case-sensitivity, you can turn it on and off.

Conclusion

Even though SQL is case-insensitive, it’s clearly a good practice to follow the convention, and this should be followed by anyone using SQL, MySQL, Oracle SQL, and any other database management systems.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top