Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rename tablenames to UPPERCASE

Tags:

mysql

I've found several scripts, similar to this below, online that gives a preview how all table names gonna look like once I fire the script:

select concat('RENAME TABLE ', TABLE_NAME, ' TO ', UPPER(TABLE_NAME), ';') from information_schema.TABLES where TABLE_SCHEMA = 'your_db'

But what I need is an upgrade script that actually updates the the table names in the db, and not just let me preview the names.

I'm aware of these buddies:

lower_case_table_names = 1
lower_case_file_system = 1

but this in not an option due to the fact that I cannot make changes in the .ini file on my domain - so rather than have to rename each table online I prefer an simple script that renames (and saves) all table names at once... - and how would such update-script look like...?

like image 494
Robin Hansen Avatar asked Dec 02 '22 23:12

Robin Hansen


1 Answers

I had similar problems when my hosting company moved MySQL database from Windows to Linux, had to change all tables names to uppercase:

First run this in the SQL window of phpmyadmin

select concat('rename table ', table_name, ' to ' , upper(table_name) , ';') from information_schema.tables where table_schema = 'your_schema_name';

this produces a script that will change all tables names to uppercase copy the script and paste it into the SQL window and run.

like image 99
BigBlue Avatar answered Dec 31 '22 12:12

BigBlue