关联 系统表,实例sql如下。看看 select * information_schema.TABLES where table_schema='test' and table_name='test';
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;这样判断
create procedure sp() begin if exists(select 1 from information_schema.TABLES where table_schema='test' and table_name='test') then insert into test values(1); end if;end;
谢谢大家,我是这么解决的,用这个SQL语句“SHOW TABLES LIKE 'table%'”,找出所有匹配的表,然后在JAVA程序中按天循环,再从中匹配,这样就不会出错了
select * information_schema.TABLES
where table_schema='test' and table_name='test';
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;这样判断
create procedure sp()
begin
if exists(select 1 from information_schema.TABLES where table_schema='test' and table_name='test') then
insert into test values(1);
end if;end;