Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL and Case Insensitive Conditions

I have noticed in MySQL a where clause like WHERE x = 'Test' will match regardless of case ('TEST', 'test', etc.)

When using PDO, is it fair to assume that this is the case with most database servers? For example, If I were to use MSSQL or Oracle, would this be the same case?

like image 913
Lea Hayes Avatar asked Jul 25 '11 18:07

Lea Hayes


2 Answers

It's not the server that it depends on, but the collation. Most databases will default to a case insensitive collation, so you can assume that, but if you ever run into one that is case sensitive it is easy to change.

like image 127
Paul Avatar answered Sep 24 '22 01:09

Paul


Oracle is case sensitive with data by default e.g.

select * from 'test';

does not equal

select * from 'TEST';

Been a while since I last used them but I seem to recall Informix beiung case sensitive and Sybase I think is dependant on the collation.

As noted by other respondandt SQL Server is dependant on the collation.

So I think the only real answer is it depends on the RDBMS

like image 36
Karl Avatar answered Sep 26 '22 01:09

Karl