I am new to MySQL, and I have a sc开发者_运维技巧ript that is supposed to rename all tables to uppercase. I have an error in it , but I can't figure out why it is not working. Any help is appreciated!
DECLARE a VARCHAR(100);
DECLARE done INT DEFAULT 0;
DECLARE cur1 CURSOR FOR
SELECT DISTINCT table_name
FROM information_schema.columns
WHERE table_schema='admin27_shop';
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done=1;
OPEN cur1;
read_loop: LOOP
FETCH cur1 INTO a;
IF done THEN
LEAVE read_loop;
END IF;
CREATE TABLE CONCAT(a, '1') SELECT * FROM a;
DROP TABLE a;
RENAME TABLE CONCAT(a, '1') TO UPPER(a);
END LOOP;
CLOSE cur1;
UPDATE: The error message happens on line 1, at the declaration of the variable, says that there is a syntax error...
Must be my specific version of MySQL and the application. Closing this question.
精彩评论