if exists(
select 1 from all_all_tables t where t.table_name = 'aaaa')
then
select * from aaaa
else
create table aaaa
select 1 from all_all_tables t where t.table_name = 'aaaa')
then
select * from aaaa
else
create table aaaa
解决方案 »
- oracle 嵌套表的用法
- oracle 自定义函数里有个nvl()
- sqlldr
- “将表BASE_DOC_ITEM_RL的外键FK_BASE_DOC_ITEM_RL1设置为Cascade”
- 如何加快 insert 语句的插入时间?????????
- oracle别名中如何使用特殊字符(/,#,&)?
- 关于存储过程和触发器
- 一个关于序列的问题
- Select * From PayInvoice Where Uptodate =2002-12-31 为什么没有返回值
- 一个奇怪的现象,用sum统计合计金额,结果结果同一条语句,不同的时间统计的数字不一样,一会儿10万,一会儿4万,谁遇见过这种情况。
- 帮帮忙,为什么我的数据插不进去呢?
- 存储过程的问题!请大家指教!
declare
v_count number;
begin
select count(*) into v_count
from user_tables
where table_name = 'AAA';
if v_count > 0 then
select * from aaa;
else
execute immediate 'create table aaa(a int)';
end if;
end;
oracle中类似于zsfww1205(努力学习oracle)所说的语句存在吗?
语句执行有错误。帮忙再看看。
v_count number;
begin
select 1 into v_count from all_all_tables t where t.table_name = 'AAA';
if v_count > 0 then
select * from aaa;
else
execute immediate 'create table aaa(a int)';
end if;
end;
注意搂住的要求是只要存在表就“select * from aaa”,而不是有数据才进行选择
语句执行仍有错误。错误同上。表或视图不存在。
再帮忙看看吧。
2 v_sql varchar2(200);
3 v_temp number;
4 begin
5 select max(1) into v_temp from user_tables where table_name='TT';
6 if v_temp is null then
7 execute immediate 'create table tt (col number)';
8 else
9 execute immediate 'select col from tt where rownum=1' into v_temp;
10 end if;
11 dbms_output.put_line(v_temp);
12 end;
13 /PL/SQL 过程已成功完成。已用时间: 00: 00: 01.12
SQL> desc tt;
名称 空? 类型
----------------------------------------- -------- -----------------------
COL NUMBERSQL> insert into tt values (11);已创建 1 行。已用时间: 00: 00: 00.50已用时间: 00: 00: 00.00
SQL> set serveroutput on
SQL> declare
2 v_sql varchar2(200);
3 v_temp number;
4 begin
5 select max(1) into v_temp from user_tables where table_name='TT';
6 if v_temp is null then
7 execute immediate 'create table tt (col number)';
8 else
9 execute immediate 'select col from tt where rownum=1' into v_temp;
10 end if;
11 dbms_output.put_line(v_temp);
12 end;
13 /
11PL/SQL 过程已成功完成。已用时间: 00: 00: 00.00
SQL>