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 _ e-mail '('email '),
KEY 'idx _ channel_id '('Channel _ id ')
) ENGINE = MyISAM default charset = utf8 ;');
Prepare stmt from @ s;
Execute stmt;
DEALLOCATE prepare stmt;
End