create or replace procedure name_pro
as
v_sql1 varchar2(4000);
isExists number(2);
cursor checkExists is select count(1) from all_tables where owner='ZHENYUAN' AND TABLE_NAME='TABLENAME';
begin
open checkExists;
fetch checkExists into isExists;
if isExists=1 then
execute immediate 'drop table temp_table_1';
end if; v_sql1 := 'CREATE GLOBAL TEMPORARY TABLE temp_table_1 ON COMMIT PRESERVE ROWS as select * from ...';
execute immediate v_sql1;
end;跟表名没有关系,主要是思路,多谢各位
as
v_sql1 varchar2(4000);
isExists number(2);
cursor checkExists is select count(1) from all_tables where owner='ZHENYUAN' AND TABLE_NAME='TABLENAME';
begin
open checkExists;
fetch checkExists into isExists;
if isExists=1 then
execute immediate 'drop table temp_table_1';
end if; v_sql1 := 'CREATE GLOBAL TEMPORARY TABLE temp_table_1 ON COMMIT PRESERVE ROWS as select * from ...';
execute immediate v_sql1;
end;跟表名没有关系,主要是思路,多谢各位
解决方案 »
- 【求助】Oracle 9.0 Library帮助文档有没有中文版可以下载啊???
- 如何在oracle中创建自定义类型。
- 按日期分区表错误
- sql语句中的as可以这么用吗
- .bat文件怎么转换成linux的.sh文件
- 定时自动导出dmp,我想用系统日期时间拼成文件名,在EXP批处理中怎样写?
- 按部门合计SAL值?
- 请帮忙将sqlserver上的SQL语句转换成oracle的标准语句
- 这个存储过程while里面的update为什么不起作用,又不报错! 在线等,高手请进,UP有分!
- 得到所有oracle数据库的名字
- 兼职开发oracle+delphi软件
- 如何将ORACLE8i导出的数据库导入ORACLE7.3中,在线等待,急!!!!
删除( On commit delete rows)还是session(On commit preserve rows) 结束后删除就可以自动删除了
2、在过程里,用动态sql来实现咯
而且进程进行表的删除会造成很多碎片,使服务器性能下降。
我看你的过程里面是建立临时表,而不是删除,删除表使用drop
在存储过程中
1。判断临时表是否存在,如果不存在创建;
2。如果临时表存在,因为是不同的会话,是看不到其中的数据的,那么向其中插入数据(因为drop表是会引起并发问题的)
这样考虑对吗?另外,大虾,如果方便,能不能给我一个相关的例子参考一下。。
多谢了!
'CREATE GLOBAL TEMPORARY TABLE temp_table_1 ON COMMIT PRESERVE ROWS as select * from ...';与
'CREATE GLOBAL TEMPORARY TABLE temp_table_1 ON COMMIT PRESERVE ROWS as select * from ... where 1=2'结果一样,没有数据的,只存在结构,想要数据,要多一个步骤:
insert into temp_table_1 select * from ...;