Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there an 'official' convention on whether SQL functions should be capitalized? [closed]

I read a bunch of the articles a questions asking about capitalizing SQL keywords (SELECT, FROM, WHERE, etc.), but I couldn't find a thread for the following:

Should I capitalize SQL functions, like SUM(), COUNT(), etc.? The teacher of a class I took used to capitalize the functions, but a software engineer at work told me not to.

Is there a convention?

like image 360
Leon S Avatar asked Nov 02 '25 09:11

Leon S


2 Answers

In short, it really comes down to personal preference/style. It's a traditional convention that's been around for ages to always use upper case letters for reserved words in SQL (see here: https://www.sqlstyle.guide/#query-syntax) and the idea is that even if someone is not using an IDE that highlights the reserved words, they can still easily differentiate between the reserved keywords and other stuff such as column and table names.

Personally, I think capitalizing the reserved words just makes the SQL code look like it's from 30 years ago and constantly using shift or caps lock while typing is just not something I want to do. There are auto-formatting extensions that you can use but honestly...why?

like image 98
samredai Avatar answered Nov 03 '25 23:11

samredai


Yes, capitalizing SQL statements is a convention and I strongly suggest to use it. Like others wrote in this thread it really helps with reading scripts (you will see that they can be really big).

T-SQL conventions from MS: link

like image 22
Beniamin Makal Avatar answered Nov 03 '25 23:11

Beniamin Makal



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!