How to make MySQL colum name case insensitive in Cent OS?
It depends from the type of the table you create.
For strings (CHAR, VARCHAR, TEXT), string searches use the collation of the comparison operands.
http://dev.mysql.com/doc/refman/5.7/en/case-sensitivity.html
for exemple if the table collation is utf8_general_ci the _CI indicates case insensitive
else the collation utf8_general is case sensitive
you can easily change the collation of your table with an update.
example of a CASE INSENSITIVE TABLE (utf8_general_ci)
CREATE TABLE `test` (
`id` VARCHAR( 32 ) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL ,
`value1` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL
) ENGINE = MYISAM CHARACTER SET utf8 COLLATE utf8_general_ci
example of a CASE SENSITIVE TABLE (utf8_general)
CREATE TABLE `test` (
`id` VARCHAR( 32 ) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL ,
`value1` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general NOT NULL
) ENGINE = MYISAM CHARACTER SET utf8 COLLATE utf8_general
Also if you want you can change the default collaction as explained here https://dev.mysql.com/doc/refman/5.7/en/charset-syntax.html
There are default settings for character sets and collations at four levels: server, database, table, and column.
Are table names in MySQL case sensitive?
In general:
Database and table names are not case sensitive in Windows, and case sensitive in most varieties of Unix.
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. Consequently, the case sensitivity of the
underlying operating system plays a part in the case sensitivity of
database and table names.
One can configure how tables names are stored on the disk using the system variable lower_case_table_names
(in the my.cnf configuration file under [mysqld]).
Read the section: 10.2.2 Identifier Case Sensitivity for more information.
How do I override MySQL Case Sensitivity on per database or table base?
Unfortunately there is no per DB setting present. Per MySQL Documentation you can use lower_case_table_names
system variable while starting mysqld
but that as well Global and not a per DB solution which you are looking for. As already commented by @cris85 ... linked documentation also states below alternative
To convert one or more entire databases, dump them before setting
lower_case_table_names
, then drop the databases, and reload them
after settinglower_case_table_names
:Use
mysqldump
to dump each database:mysqldump --databases db1 > db1.sql
mysqldump --databases db2 > db2.sql
...
Do this for each database that must be recreated.
Use
DROP DATABASE
to drop each database.Stop the server, set
lower_case_table_names
, and restart the server.Reload the dump file for each database. Because
lower_case_table_names
is set, each database and table name will be
converted to lowercase as it is recreated:mysql < db1.sql
mysql < db2.sql
MySql - Case Sensitive issue of tables in different server
If you are using MySQL you can set table and column name case sensitive in my.conf by using following directive
set-variable = lower_case_table_names=1
Do not forget the restart server after update. It would be better if you use same column names in all servers
lower_case_table_names Settings in MySQL 8.0.12
As per this link, lower_case_table_names should be set together with --initialize option.
Related Topics
Split Comma Separated Column Data into Additional Columns
Listagg Function: "Result of String Concatenation Is Too Long"
Column Calculated from Another Column
Group by Minimum Value in One Field While Selecting Distinct Rows
How to Pass Column Name as Input Parameter in SQL Stored Procedure
Return Default Result For in Value Regardless
Function Vs. Stored Procedure in SQL Server
Update Multiple Rows With Different Values in One Query in MySQL
In MySQL Queries, Why Use Join Instead of Where
Simplest Way to Do a Recursive Self-Join
The Multi-Part Identifier Could Not Be Bound
Difference Between Language SQL and Language Plpgsql in Postgresql Functions
Maximum Size For a SQL Server Query? in Clause? Is There a Better Approach