declare
countq number;
begin
select count(table_name) into countQ from all_tables where table_name='TEST';
if(countQ>0) then
execute immediate 'drop table test';
else
execute immediate 'create table test...';
end if;
end;
countq number;
begin
select count(table_name) into countQ from all_tables where table_name='TEST';
if(countQ>0) then
execute immediate 'drop table test';
else
execute immediate 'create table test...';
end if;
end;
解决方案 »
- 无法以sysdba的角色登陆数据库
- question
- 在线求救!!动态SQL的问题!!!
- 如何启动oracle服务
- 当是二行数据时,如何求出平均值,当是一行时就无须求平均值
- Installing Oracle9i Database on Red Hat Linux 9
- win2000下安装Oracle9i在运行Database Configuration Assistant 创建数据库时出错!
- 在linux下用proc编译程序,'*.pc'文件编译后成了'*.c?',多了一个问号?
- 如何复制一个含有LONG RAW字段的表
- 关于oracle816中的syaman密码问题(急!在线等待中!高分)
- Windwos下编写的软件是否可以直接操作UNIX下的oracle?
- 有关%rowtype的问题,在线等待
2 begin
3 execute immediate 'drop table tb1';
4 exception when others then
5 null;
6 end;
7 execute immediate 'create table tb1(
8 aa number,
9 bb number)';
10 end;
11 /PL/SQL 过程已成功完成。SQL>
select count(table_name) into countQ from all_tables where table_name='TEST';
你要判断的表名替代代码中的'TEST'就行了
要是表不存在,countq就为0;存在,countq就为1啊。
直接用exception 处理就行了。