Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is data stored in tables case sensitive?

I have three table samples. I have used mysql to store data in database

+--------------------------+
| Table-1                  |
+--------------------------+
| Sl.No | Name | City      |
+-------+------+-----------+
|  1    | Carl | Australia |
+-------+------+-----------+

+--------------------------+
| Table-1                  |
+--------------------------+
| Sl.No | Name | City      |
+-------+------+-----------+
|  1    | carl | australia |
+-------+------+-----------+

+--------------------------+
| Table-1                  |
+--------------------------+
| Sl.No | Name | City      |
+-------+------+-----------+
|  1    | CARL | AUSTRALIA |
+-------+------+-----------+
  • clearly we can see one row of data in each table
  • nature of data is same

what I have done is I have used different case letters some are uppercase letters and some are lowercase letters.

Are data stored in database case sensitive?

like image 682
Devrath Avatar asked Oct 03 '13 17:10

Devrath


People also ask

Are tables case sensitive?

Table names are stored in lowercase on disk and name comparisons are not case-sensitive. MySQL converts all table names to lowercase on storage and lookup. This behavior also applies to database names and table aliases.

Is data in database case sensitive?

Database case-sensitivity considerations for when specifying the select query. Most databases treat table column names as case-insensitive. However, some databases, for example Sybase, treat table column names as case-sensitive.

Is data stored in SQL case sensitive?

The SQL keywords (SELECT, FROM, WHERE, etc.) are case-insensitive, yet they are frequently expressed in all capitals. Table and column names are case-sensitive in some settings.

Is SQL table column name case sensitive?

MS SQL Server The column names in a select statement are not case sensitive even if quoted.


2 Answers

Data is just stored as raw data. However if you want to get the data in any particular format you can format it. You may insert the data as per your convinience however internally they are interpreted the same ie, ABC is same as abc and aBc

By default MySQL queries are not case-sensitive.

From the MySQL site

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. One notable exception is Mac OS X, which is Unix-based but uses a default file system type (HFS+) that is not case sensitive. However, Mac OS X also supports UFS volumes, which are case sensitive just as on any Unix.

On a side note:-

Inside the database, all data is stored in binary format. You can have different data types which is used by the computer to interpret how to show the data to the user, but that is just a mask.

like image 93
Rahul Tripathi Avatar answered Oct 09 '22 09:10

Rahul Tripathi


yes, the database stores the data how you submit it.

if you say:

INSERT INTO MyTable (LowerCase, UpperCase) VALUES ("abcd", "ABCD");

it will insert:

LowerCase | UpperCase
abcd      | ABCD

if you do

INSERT INTO MyTable (LowerCase, UpperCase) VALUES ("AbCd", "aBcD");

it will insert:

LowerCase | UpperCase
AbCd      | aBcD

it's up to you to sanitize the inputs to the case you want, or just let it go as entered.

however, when I do a

SELECT * FROM MyTable WHERE LowerCase="abcd";

it will return both entries.

like image 5
Snowburnt Avatar answered Oct 09 '22 10:10

Snowburnt