Sunday, March 24, 2019

php - mysql case sensitive table names in queries



I have php code where first letter of database table names is in capital letter every where but table names in database are in lowercase.



What global setting should I use so that no need to change in every code file for making table names in same case as in database.



Answer



MySQL metadata is case sensitive by default on Linux. That is if you have a table my_table, in lower case, then



select * from my_table


will succeed while



select * from MY_TABLE



will fail with some sort of table doesn't exist message.



If you want both statements to succeed, you need to put the following line
lower_case_table_names = 1
in your /etc/my.cnf or wherever you keep your MySQL configuration. Be sure to add the system variable to [mysqld] section of the configuration file.


No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...