比特网
开始
声明 date_str varchar(8);
声明 table_prefix varchar(20);
设置 table_prefix='mail_rare_visit_';
设置 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_INCRMENT,
`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` 小数(7,6) NOT NULL DEFAULT 0.000000,
`w_buy` 小数(7,6) NOT NULL DEFAULT 0.000000,
`w_browse` 小数( 7,6) NOT NULL DEFAULT 0.000000,
`rec_goods` varchar(800) DEFAULT NULL,
`update_time` 时间戳 NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
主键 (`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;');
从 @s 准备 stmt;
执行 stmt;
解除分配准备 stmt;
结束