I recently transferred a database from a windows box to a linux box. The tables are mixed between lower and upper case names. I need a way to rename all tables and columns to lowercase. Is that possible?
I see in this SO answer it's possible for tables, but have not found anything that deals with column names.
The LOWER() function converts a string to lower-case. Note: The LCASE() function is equal to the LOWER() function.
Use the SQL LOWER() function if you want to convert a string column to lowercase. This function takes only one argument: the column whose values you want to lowercase.
Column, index, stored routine, and event names are not case-sensitive on any platform, nor are column aliases. However, names of logfile groups are case-sensitive.
You can try to do exact same thing with Information_Schema.Columns table
EDIT: Something like
SELECT CONCAT('ALTER TABLE ', TABLE_NAME, ' CHANGE `', COLUMN_NAME, '` `',
LOWER(COLUMN_NAME), '` ', COLUMN_TYPE, ';')
FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = '{your schema name}'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With