Sefam
Sefam

Reputation: 1773

Case on PHP SQL queries different from case on MySQL database. Cannot use lower_case_table_names = 1

I'm having an issue with a website I wrote in PHP on a WAMP server on Windows, issue is, it's now being deployed on a Linux server. The site is quite big and I've done all my queries this way in all caps:

"SELECT COLUMN FROM TABLE"

And most of the tables/columns in the database use a different case (For example, Column).

I cannot use lower_case_table_name=1 since there are other PHP websites on the server that would be affected negatively. Is there a way for me to switch all of my database's tables and columns into upper case?

Upvotes: 0

Views: 114

Answers (2)

M Khalid Junaid
M Khalid Junaid

Reputation: 64476

you have change the names of columns and tables if you database is not so huge you can try this

select concat('rename table ', column_name, ' to ' , lower(column_name) , ';') 
from information_schema.columns where table_schema = 'your_schema_name';

and rename or change the case for more help see and lower_case_table_names

Upvotes: 1

Lawson
Lawson

Reputation: 634

ALTER TABLE yourtablename RENAME TO YOURTABLENAME;

Upvotes: 0

Related Questions