DROP PROCEDURE IF EXISTS 'PROC_ADD_TPROTOCOL'; CREATE PROCEDURE `PROC_ADD_TPROTOCOL`()begin if exists(SELECT table_name FROM information_schema.TABLES WHERE table_name ='tprotocol') then alter table tprotocol add Lx64Length int(4) not null default '0'; alter table tprotocol add Lx64Content mediumblob null; end if; end;这样可以吗
可以,也可以 SELECT count(*) into @tt FROM information_schema.TABLES WHERE table_name ='tprotocol'; if @tt>1 then 你的语句 end if
可以先show tables like 'xxxx'; 然后根据结果的FOUND_ROWS()判断表是否存在。
DROP PROCEDURE IF EXISTS 'PROC_ADD_TPROTOCOL';
CREATE PROCEDURE `PROC_ADD_TPROTOCOL`()begin
if exists(SELECT table_name FROM information_schema.TABLES WHERE table_name ='tprotocol') then
alter table tprotocol add Lx64Length int(4) not null default '0';
alter table tprotocol add Lx64Content mediumblob null;
end if;
end;这样可以吗
SELECT count(*) into @tt FROM information_schema.TABLES WHERE table_name ='tprotocol';
if @tt>1 then
你的语句
end if