Sql-server – SQL Server on Linux: Case Sensitivity

case sensitivelinuxsql serversql-server-2017

I haven’t yet tried out SQL Server on Linux, but I have a question regarding case sensitivity.

In MySQL and Oracle (as far as I am aware) table names and database names are case insensitive on Mac & Windows, but case sensitive on Linux. I understand this has something to do with the case sensitivity of the underlying OS.

PostgreSQL, on the other hand, doesn’t work that way.

The question is: are database and table names in SQL Server on Linux case sensitive?

I ask this because I always recommend sticking to the case in which names are defined, but I want to check whether it is also future-proofing the project.

Best Answer

It has nothing to do with the underlying OS. It has to do with the collation of the instance and the collation of the database. Here is an example that shows that database names, table names, column names, and data are not subject to case sensitivity by default.

enter image description here

If you want those things, you can turn them on, by specifying a case-sensitive collation for the column, for the database, or - I think - for the instance. (The images I've been using for SQL Server Docker containers don't have the traditional setup package where you can pick instance collation prior to setup, and changing instance collation after the fact might not be fun.)

Perhaps you're thinking about physical files? I know when I was moving my stuff from IIS to a Unix host I had to change references to things like file.css because the file on disk was actually File.css and the server wouldn't be able to locate it. SQL Server doesn't work that way.

Regardless

Yes, you should absolutely stick to the proper casing of things, and that future-proofs you no matter what operating system you use to host SQL Server. Anybody can come along and change the collation of various bits of your installation (or deploy your code to a place where the collation is already different). See these articles: