mysql存储过程变量作表名
时间:2007-11-08 来源:wuruichang
delimiter //
CREATE PROCEDURE create_report(CustomId int)
BEGIN SET @sqltext:=concat('CREATE TABLE Report_',CustomId,' (id INT NOT NULL ,name VARCHAR( 16 ) NOT NULL ,PRIMARY KEY ( id ) ) ENGINE = MYISAM ');
PREPARE sqlstr from @sqltext;
Execute sqlstr;
END;
//
使用: call create_report(9);
CREATE PROCEDURE create_report(CustomId int)
BEGIN SET @sqltext:=concat('CREATE TABLE Report_',CustomId,' (id INT NOT NULL ,name VARCHAR( 16 ) NOT NULL ,PRIMARY KEY ( id ) ) ENGINE = MYISAM ');
PREPARE sqlstr from @sqltext;
Execute sqlstr;
END;
//
使用: call create_report(9);
相关阅读 更多 +