Mysql 动态SQL 应用

DELIMITER $$

DROP PROCEDURE IF EXISTS `tempdb`.`test`$$

CREATE DEFINER=`jx`@`%` PROCEDURE `test`(table_date varchar(20))
    BEGIN
	set @DYNCSQL = CONCAT('rename table d_referrer_201208 to d_referrer_',table_date);
	prepare stmt1 from @DYNCSQL;
	execute stmt1;
    END$$

DELIMITER ;


你可能感兴趣的:(mysql)