您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

深入mysql存储过程中表名使用参数传入的详解_MySQL

2024/5/17 6:41:40发布22次查看
bitscn.com
begin
declare date_str varchar(8);
declare table_prefix varchar(20);
set table_prefix='mail_rare_visit_';
set date_str = date_format(current_date(),'%y%m%d');
set @table_name = concat(table_prefix, date_str);
set @s = concat('create table ', @table_name, '(
  `id` int(11) not null auto_increment,
  `user_id` int(11) not null,
  `city_id` int(11) not null,
  `email` varchar(300) not null,
  `channel_id` int(11) default null,
  `w_revenue` decimal(7,6) not null default  0.000000,
  `w_buy` decimal(7,6) not null default 0.000000,
  `w_browse` decimal(7,6) not null default 0.000000,
  `rec_goods` varchar(800) default null,
  `update_time` timestamp not null default current_timestamp on update current_timestamp,
  primary key (`id`),
  key `idx_user_id` (`user_id`),
  key `idx_city_id` (`user_id`),
  key `idx_email` (`email`),
  key `idx_channel_id` (`channel_id`)
) engine=myisam default charset=utf8;');
prepare stmt from @s;
execute stmt;
deallocate prepare stmt;
end
bitscn.com
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product