复制主表结构并创建
SET @sqlstr = CONCAT('create table you_table_',DATE_FORMAT(CURDATE(),'%Y%m%d'),' like you_table');
PREPARE stmt1 FROM @sqlstr ;
EXECUTE stmt1 ;
复制主表数据
SET @sqlstr = CONCAT('insert into you_table_',DATE_FORMAT(CURDATE(),'%Y%m%d'),' select * from you_table');
PREPARE stmt1 FROM @sqlstr ;
EXECUTE stmt1 ;
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/tech/database/289435.html