应该没有吧,用过程吧。 判断表是否存在: select count(1) from all_tables where table_name='新表名' and owner='用户名';
select count(*) from user_tables where table_name = '表名' ;drop table 表名;
判断表是否存在: select count(*) from user_tables where table_name = '表名' ; 如果count(*)>0存在,=0不存在 注意:表名需要大写删除表 drop table 表名;
在存储过程里该如何写? 能 if(select count(*) from user_tables where table_name = '表名')>0 then drop table 表名; end if吗?
在存储过程里 select count(*) into i_Count from user_tables where table_name = '表名'; if(i_Count>0) then drop table 表名; end if;
drop table 表名;的时候要用动态sql
create or replace test is v_count number; begin select count(*) into v_count from all_tales where table_name='yourtabel 注意大写'; if v_count <> 0 then drop table yourtable; commit; end if; end; end test; 大概意思就是这样,我也没有调过!
判断一个表是否存在,若存在并先DROP它!!! 这个问题很好回答!! drop table talbe_name; 若是这个表存在那么,那么提示drop成功!! 如果这个表不存在,那么会提示没有找到相应的表!!
判断表是否存在:
select count(1) from all_tables where table_name='新表名' and owner='用户名';
select count(*) from user_tables where table_name = '表名' ;
如果count(*)>0存在,=0不存在
注意:表名需要大写删除表
drop table 表名;
能
if(select count(*) from user_tables where table_name = '表名')>0 then
drop table 表名;
end if吗?
select count(*) into i_Count from user_tables where table_name = '表名';
if(i_Count>0) then
drop table 表名;
end if;
v_count number;
begin
select count(*) into v_count from all_tales where table_name='yourtabel 注意大写';
if v_count <> 0 then
drop table yourtable;
commit;
end if;
end;
end test;
大概意思就是这样,我也没有调过!
这个问题很好回答!!
drop table talbe_name;
若是这个表存在那么,那么提示drop成功!!
如果这个表不存在,那么会提示没有找到相应的表!!
先drop 你要建的table_name
然后create 你的table_name
就ok了