Do all table names have to have capital letters?



Do all table names have to have capital letters?


Many developers capitalize a table name for the sake of differentiating it from the column names, although the most common convention is to have table and column names in all lowercase to have a more legible contrast on a written query but then again it is also possible to do the contrary and have table and column names all uppercase and keywords in lower case, let’s see their comparison:

SELECT * FROM table WHERE table_name = 'My table';

/*it can be with capitalized table name*/

SELECT * FROM Table WHERE table_name = 'My table';

/*or it can have all uppercase and keywords lowercase*/

select * from TABLE where TABLE_NAME = 'My table';

As we may see, it is much to preference and also sometimes the tools used, SQLite does not have restrictions that I am aware of on this subject, yet MySQL does have some. The main thing to keep in mind on our decision is to make sure that once created we do not try to go back an forth on how we write our queries, simply because SQL is case sensitive, so if we created a table called My_First_Table, and we try to SELECT * FROM my_first_table; we will find that table does not exist. It is the SQL-92 standard that specifies all identifiers and keywords are case-insensitive.

So if we have the chance to decide, let’s stick to it, otherwise, most commonly we will work with code already created by others, so we will need to respect their preference on how it is written.