Jump to content

Check out our Community Blogs

Register and join over 40,000 other developers!

Recent Status Updates

View All Updates

- - - - -

Is MySQL case sensitive?

case sensitive mysql

  • Please log in to reply
9 replies to this topic

#1 yooj


    CC Lurker

  • Just Joined
  • Pip
  • 1 posts

Posted 26 August 2007 - 11:37 AM

The title says it all. Is MySQL case sensitive? :cool:
  • 0

#2 Guest_Jordan_*

  • Guest

Posted 28 August 2007 - 04:45 AM

I believe it depends on the Operating System you have MySQL on. I could be wrong though:

Although database and table names are not case sensitive on some platforms, you should not refer to a given database or table using different cases within the same statement. The following statement would not work because it refers to a table both as my_table and as MY_TABLE:

mysql> [B]SELECT * FROM my_table WHERE MY_TABLE.col=1;

MySQL AB :: MySQL 5.0 Reference Manual :: 8.2.2 Identifier Case Sensitivity
  • 0

#3 shri_bill


    CC Lurker

  • New Member
  • Pip
  • 3 posts

Posted 18 January 2011 - 02:03 AM


I'm a Linux user, as we know Unix-based operating systems are strictly a case-sensitive. But even on Linux, mysql client's commands, SQL commands (in accordance with SQL standards) and function-names etc. are NOT case-sensitive, i.e. both 'select' and 'SELECT' are perfectly valid, however entity-names such as names of tables and databases are case-sensitive, i.e. if a table's name is 'Customer', we cannot use 'customer' or 'CUSTOMER'. Once again, remember: even though table-names are case-sensitive, column-names are not.

Aditya Shrivastava
Let's create a "suffering free world" BKWSU.com :).

Edited by shri_bill, 18 January 2011 - 02:47 AM.

  • 0

#4 Orjan


    CC Mentor

  • Moderator
  • 2918 posts
  • Location:Karlstad, Sweden
  • Programming Language:C, Java, C++, C#, PHP, JavaScript, Pascal
  • Learning:Java, C#

Posted 19 January 2011 - 05:48 PM

SQL itself isn't case sensitive, but it can be on searching data, all depends on the table collation settings.
  • 0

I'm a System developer at XLENT Consultant Group mainly working with SugarCRM.
Please DO NOT send mail or PM to me with programming questions, post them in the appropriate forum instead, where I and others can answer you.

#5 DarkLordCthulhu


    CC Devotee

  • Senior Member
  • PipPipPipPipPipPip
  • 422 posts
  • Location:The bash shell
  • Programming Language:C, JavaScript, Bash, Others
  • Learning:Ruby, Others

Posted 21 January 2011 - 02:26 PM

  • 0
Programming is a journey, not a destination.

#6 Alhazred


    CC Addict

  • Advanced Member
  • PipPipPipPipPip
  • 133 posts

Posted 24 January 2011 - 11:45 AM

MySQL syntax is not case sensitive, you can write
select * from table where...
SeLEct * FroM table WHerE
or whatever else you want.

On select queries you can search for case sensitive fields values, in example if you want to find "text" inside a field but not "TEXT", "Text".... you can use

SELECT * FROM table WHERE binary(fieldname)='text';
  • 0

#7 shri_bill


    CC Lurker

  • New Member
  • Pip
  • 3 posts

Posted 15 November 2012 - 07:45 AM

In all new database-clients (regardless of OS), interaction with the MySQL server is NOT case-sensitive. This includes: standard SQL keywords, entity names, function-names etc. However certain switches in command line (in terminal) ARE case-sensitive, such as a statement terminated with \G will format the output differently than a lower-case \g or a semicolon ( ; ).

Regarding the data within the database, I agree with "Alhazred" that we can use the binary() function.

However the client
Aditya Shrivastava

When I change the world will change. Let's create a "suffering free world" BKWSU.com :).
  • 0

#8 KaustavBanerjee


    CC Lurker

  • Just Joined
  • Pip
  • 2 posts
  • Programming Language:C, Java, C++, PHP, JavaScript, PL/SQL
  • Learning:C#, ActionScript

Posted 15 November 2012 - 09:47 AM

mysql is never case-sensitive. and this is irrespective of the OS platform that you use.

select * from emp_table

has the same meaning and definition. In fact, the results returned for both the queries is identical. :)

However, in several cases you might find query code where the language is somewhat like this -

select * from EMP_TABLE where NAME='ABC';
SELECT * FROM emp_table WHERE name='ABC';

All these patterns and types of coding syntax are used by the programmer himself.
This helps the programmer to keep track of difference between the sql command and the relation name or attribute name.

All the best :thumbup1:

Kaustav Banerjee

Author and Owner of Programming Tutorial Blog site -
  • 0

#9 acidboy


    CC Lurker

  • Just Joined
  • Pip
  • 1 posts
  • Programming Language:C#

Posted 23 November 2012 - 07:07 AM

mysql is never case-sensitive. and this is irrespective of the OS platform that you use.

What on earth are you people talking about?


In MySQL, databases correspond to directories within the data directory. Each table within a database corresponds to at least one file within the database directory (and possibly more, depending on the storage engine). Consequently, the case sensitivity of the underlying operating system plays a part in the case sensitivity of database and table names. This means database and table names are not case sensitive in Windows, and case sensitive in most varieties of Unix.

  • 0

#10 WingedPanther73


    A spammer's worst nightmare

  • Moderator
  • 17757 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others

Posted 26 November 2012 - 06:04 AM

Okay, there are three contexts in which MySQL could be considered case sensitive:
1) low-level file structure: OS dependent
2) SQL syntax: no
3) how it treats Varchar data for comparison: this will depend on both the character set and the collation used.
  • 0

Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

My MineCraft server site: http://banishedwings.enjin.com/

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download