当前位置: 奥门金沙手机娱乐网址 > 数据库 > 正文

奥门金沙手机娱乐网址:深入mysql存储过程中表名

时间:2019-11-23 20:06来源:数据库
BEGIN declare date_str varchar;declare table_prefix varchar;settable_prefix='mail_rare_visit_';set date_str =DATE_FORMAT,'%Y%m%d');set @table_name = concat(table_prefix,date_str);set @s = concat('CREATE TABLE ', @table_name, ' NOT NULLAUTO_

BEGIN

declare date_str varchar;declare table_prefix varchar;set table_prefix='mail_rare_visit_';set date_str = DATE_FORMAT,'%Y%m%d');set @table_name = concat(table_prefix, date_str);set @s = concat('CREATE TABLE ', @table_name, ' NOT NULL AUTO_INCREMENT, `user_id` int NOT NULL, `city_id` int NOT NULL, `email` varchar NOT NULL, `channel_id` int DEFAULT NULL, `w_revenue` decimal NOT NULL DEFAULT 0.000000, `w_buy` decimal NOT NULL DEFAULT 0.000000, `w_browse` decimal NOT NULL DEFAULT 0.000000, `rec_goods` varchar DEFAULT NULL, `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY , KEY `idx_user_id` , KEY `idx_city_id` , KEY `idx_email` , KEY `idx_channel_id` ENGINE=MyISAM DEFAULT CHARSET=utf8;');

prepare stmt from @s;execute stmt;

DEALLOCATE prepare stmt;

end

编辑:数据库 本文来源:奥门金沙手机娱乐网址:深入mysql存储过程中表名

关键词: