mysql建立帶時間引數的儲存過程並呼叫
阿新 • • 發佈:2021-01-21
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);