1.
create procedure sp()
begin
if exists(select 1 information_schema.TABLES where table_schema='test' and table_name='test') then
insert into test values(1);
end if;
end;
------------------------------------------
2.
可以用IF EXISTS 选项 ;
drop table 表名 if exists 表名;
SHOW TABLES LIKE 'TB1' ;
SELECT table_name FROM information_schema.TABLES WHERE table_name ='yourname';
------------------------------------------
3.
DROP PROCEDURE IF EXISTS mydb.Clear_DB;
CREATE PROCEDURE mydb.`Clear_DB`(
)
BEGIN
DECLARE done INT DEFAULT 0; #游标的标志位
DECLARE a varchar(20);
DECLARE b varchar(20);
DECLARE cur1 CURSOR FOR SELECT table_name FROM information_schema.TABLES WHERE table_name like 'http_200909%' ;