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 (one) not NULL auto_increment,
' user_id ' int (one) is not NULL,
' city_id ' int (one) is not NULL,
' Email ' varchar not NULL,
' channel_id ' int (one) 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 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