My current approach looks like this:
DECLARE c开发者_运维百科ur CURSOR FOR SELECT table_name, COUNT(table_name) FROM INFORMATION_SCHEMA.TABLES WHERE table_schema = 'dbname';
OPEN cur;
read_loop: LOOP
FETCH cur INTO name, count;
IF done = count THEN
LEAVE read_loop;
ELSE
SET done = done + 1;
END IF;
IF SUBSTR(name, 1, 4) = 'old_' THEN
ALTER TABLE name RENAME TO UPPER(SUBSTR(name,5));
ELSE
ALTER TABLE name RENAME TO CONCAT('old_', name);
END IF;
END LOOP;
Any suggestions how to solve this?
I'm running MySQL 5.1.46 on my local machine.
MySQL is case insensitive for database scheme by default. See documentation for that. But you can enable case sensitivity from my.cnf
.
However InnoDB stores table names only with lowercase on Windows. See documentation.
精彩评论