mysql备份表sql

#不一定使用所有的表结构,但是可以参考

set @sql_create_table = concat('create table ', date_format(now(), 'BK%y%m%d_lnad_rou_audit_info '), 'like lnad_rou_audit_info;');
PREPARE sql_create_table FROM @sql_create_table;
execute sql_create_table;

set @sql_backup_table = concat('insert into ',date_format(now(), 'BK%y%m%d_lnad_rou_audit_info '),' select * from lnad_rou_audit_info');
PREPARE sql_backup_table FROM @sql_backup_table;
execute sql_backup_table;

set @sql_create_table:=NULL;
set @sql_backup_table:=NULL;

posted @ 2019-11-20 19:37  不不田鼠  阅读(1775)  评论(0编辑  收藏  举报