Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Lower case all the table names in a database?

Tags:

mysql

I have a mysql database with about 8 tables that all begin with a capital letter. Any quick way to lowercase them all? Or even one by one... if i try this, RENAME TABLE Contacts TO contacts it says ERROR 1050 (42S01): Table 'contacts' already exists

like image 976
Jonah Katz Avatar asked Oct 09 '22 01:10

Jonah Katz


1 Answers

Use two renames - first to a temp name and then to the lowercased:

RENAME TABLE Contacts TO contacts_

and then

RENAME TABLE contacts_ TO contacts

Of course, you should be careful not to try using an already existing table name, but if you initially had tables 'Contacts' and 'contacts_' I'd say you have way more serious problems than the case.

like image 78
Nikoloff Avatar answered Oct 20 '22 00:10

Nikoloff