MySQL IF THEN条件删除表

时间:2014-07-30 01:38:26

标签: mysql if-statement stored-procedures

我正在尝试使用存储过程并检查特定的表并使用IF THEN条件来删除表。是否可以在条件块中发出DROP语句?

delimiter $$

CREATE PROCEDURE FC_SQLF()

BEGIN

DECLARE SQLFOUND int;

SET @SQLFOUND = (select count(table_name) from information_schema.tables where table_schema = 'testdb' and table_name = 'temp_table');
IF @SQLFOUND = 1 THEN DROP TABLE testdb.abcd;
END IF;

END $$

0 个答案:

没有答案