您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息
三六零分类信息网 > 怀化分类信息网,免费分类信息发布

Oracle中判断有表DROP无表CREATE的存储过程

2025/7/6 19:14:05发布7次查看
create or replace procedure pd_generate_help_last_tables is--把从sqlserver中生成的vw_last_xxx所对应的视图生成本地的数据表
首页 → 数据库技术
背景:
阅读新闻
oracle中判断有表drop无表create的存储过程
[日期:2011-05-11]来源:linux社区 作者:linux[字体:]
create or replace procedure pd_generate_help_last_tables is
--把从sqlserver中生成的vw_last_xxx所对应的视图生成本地的数据表
  tabnocount number ;
  v_sql      varchar2(200);
begin
  --判断表dat_help_last_scqy1(成品油生产旬报)
  select count(*) into tabnocount from user_tables where table_name = 'dat_help_last_scqy1';
  if tabnocount>0 then
     dbms_output.put_line('drop table dat_help_last_scqy1');
     v_sql := 'drop table dat_help_last_scqy1';
     execute immediate v_sql;
  end if;
     dbms_output.put_line('create table dat_help_last_scqy1');
     v_sql := 'create table dat_help_last_scqy1 as select * from vw_last_scqy1';
     execute immediate v_sql;
  --判断表dat_help_last_scqy2(成品油生产月报)
select count(*) into tabnocount from user_tables where table_name = 'dat_help_last_scqy2';
  if tabnocount>0 then
     dbms_output.put_line('drop table dat_help_last_scqy2');
     v_sql := 'drop table dat_help_last_scqy2';
     execute immediate v_sql;
  end if;
     dbms_output.put_line('create talbe dat_help_last_scqy2');
     v_sql := 'create table dat_help_last_scqy2 as select * from vw_last_scqy2';
     execute immediate v_sql;
  --判断表dat_help_last_shsndybb(能源调度月报表)
  select count(*) into tabnocount from user_tables where table_name = 'dat_help_last_shsndybb';
  if tabnocount>0 then
     dbms_output.put_line('drop table dat_help_last_shsndybb');
     v_sql := 'drop table dat_help_last_shsndybb';
     execute immediate v_sql;
  end if;
     dbms_output.put_line('create table dat_help_last_shsndybb');
     v_sql := 'create table dat_help_last_shsndybb as select * from vw_last_shsndybb';
     execute immediate v_sql;
end pd_generate_help_last_tables;
测试
begin
  -- call the procedure
  pd_generate_help_last_tables;
end;
如果出现 ora-01031: 权限不足
ora-06512: 在system.cccccc, line 6
ora-06512: 在line 1
的错误,则执行以下授权语句
grant create table to jwdc;
grant resource to jwdc;
grant create procedure to jwdc;
0
oracle 如何判断临时表是否存在
oracle客户端连接bug
相关资讯       oracle教程
图片资讯
本文评论查看全部评论 (0)
评论声明
最新资讯
本周热门
linux公社简介 - 广告服务 - 网站地图 - 帮助信息 - 联系我们
本站(linuxidc)所刊载文章不代表同意其说法或描述,仅为提供更多信息,,也不构成任何建议。
copyright © 2006-2011 linux公社 all rights reserved 浙icp备06018118号
怀化分类信息网,免费分类信息发布

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product