1、创建表
create table aaa (id int not null auto_increment primary key,savetime datetime default null);
2、创建存储过程
delimiter //
create procedure savetoTable(in datatableName varchar(64),in savetime datetime)
begin
set @sqlcmd = concat('insert into ',datatableName,' values(null,',''+savetime+'',');');
prepare stmt from @sqlcmd;
execute stmt;
deallocate prepare stmt;
end;
delimiter;
3、调用存储过程
call savetoTable('aaa',20201011120312);