- 论坛徽章:
- 0
|
DELIMITER $$
DROP PROCEDURE IF EXISTS `short_msg`.`create_tab`$$
CREATE
[email=DEFINER=`root`@`localhost]DEFINER=`root`@`localhost[/email]
` PROCEDURE `create_tab`()
BEGIN
set @s_tabsql = 'create table s_';
set @s_tabsql = concat(@s_tabsql, adddate(curdate(), 1) + 'a');
set @s_tabsql = concat(@s_tabsql, " (
`id` int(11) NOT NULL auto_increment,
`mob_nu` varchar(20) default NULL,
`msg` varchar(200) default NULL,
`r_time` timestamp NULL default NULL,
`s_time` timestamp NULL default CURRENT_TIMESTAMP,
`class` tinyint(4) default '0',
PRIMARY KEY (`id`)
)");
PREPARE stmt1 FROM @s_tabsql;
EXECUTE stmt1;
set @r_tabsql = 'create table r_';
set @r_tabsql = concat(@r_tabsql, adddate(curdate(), 1) + 'a');
set @r_tabsql = concat(@r_tabsql, " (
`id` int(11) NOT NULL auto_increment,
`mob_nu` varchar(20) default NULL,
`msg` varchar(200) default NULL,
`r_time` timestamp NULL default NULL,
`s_time` timestamp NULL default CURRENT_TIMESTAMP,
`class` tinyint(4) default '0',
PRIMARY KEY (`id`)
)");
PREPARE stmt2 FROM @r_tabsql;
EXECUTE stmt2;
END$$
DELIMITER ;
本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u2/71471/showart_1003010.html |
|