Mysql 存储过程实现表引擎转换(实现一半)

CREATE DEFINER=`root`@`%` PROCEDURE `test2`()
BEGIN


      DECLARE _table_name varchar(50) ;
      DECLARE _sql varchar(5000) DEFAULT '';
      DECLARE Done        INT DEFAULT 0;


      DECLARE rs CURSOR FOR  SELECT table_name FROM information_schema.TABLES WHERE table_schema='kingdom_db' ;
      DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET Done = 1;
      OPEN rs ;


      FETCH NEXT FROM rs INTO _table_name;


      REPEAT
                IF NOT Done THEN
                     Set _sql = CONCAT(_sql,' ALTER TABLE  ',_table_name,' ENGINE = INNODB;');


                END IF;


                FETCH NEXT FROM rs INTO _table_name;


      UNTIL Done END REPEAT;
      delete from   `errors` ;
      Insert into `errors` set `uid`=1, `data`=  _sql;
      CLOSE rs ;




END
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页