您的当前位置:首页正文

切表之批量建表

2024-11-08 来源:个人技术集锦
DROP PROCEDURE IF EXISTS `create_tables`;
DELIMITER //
CREATE PROCEDURE `create_tables`()
BEGIN
DECLARE i INT;
SET i=0;
WHILE i<6 DO
SET @create_sql=CONCAT('create table t_system',i,'(like t_system);');
PREPARE stmt FROM @create_sql;
EXECUTE stmt;
SET i=i+1;
END WHILE;
END //
CALL create_tables
Top