美文网首页
2018-11-21 oracle重复提交多个表

2018-11-21 oracle重复提交多个表

作者: 妖怪在流浪 | 来源:发表于2018-11-21 10:00 被阅读1次

两种方式
第一种:开始和结尾加 begin end

begin
declare
      num   number;
begin
  --TMP_USP_PLAT_CZRYQUERY_RESULT
  select count(1) into num from user_tables where table_name = upper('TMP_USP_PLAT_CZRYQUERY_RESULT');
  if num > 0 then execute immediate
  'drop table TMP_USP_PLAT_CZRYQUERY_RESULT';
  end if;
  
  select count(1) into num from user_tables where table_name = upper('TMP_USP_PLAT_CZRYQUERY_RESULT');
  if num = 0 then execute immediate
   'create global temporary table TMP_USP_PLAT_CZRYQUERY_RESULT
  (
    zclsh   VARCHAR2(64),
    rybm    VARCHAR2(64),
    jgbm    VARCHAR2(64),
    jgjc    VARCHAR2(64)
  )on commit preserve rows';
  end if;
end;

 declare
  num number;
begin
 
 select count(1) into num from user_tables where table_name = upper('TMP_USP_QUERY_ZDMLDZ_PARA');
    if num = 0 then execute immediate'
create global temporary table TMP_USP_QUERY_ZDMLDZ_PARA
(
  jgbm  VARCHAR2(22),
  zlmc  VARCHAR2(64),
  zldm  VARCHAR2(36),
  jsnum VARCHAR2(10)
)on commit preserve rows
';end if;
end;
end;

第二种:如果声明多个变量,每个表加结尾斜杠 / , declare声明 之前

declare
      num   number;
begin
  --TMP_USP_PLAT_CZRYQUERY_RESULT
  select count(1) into num from user_tables where table_name = upper('TMP_USP_PLAT_CZRYQUERY_RESULT');
  if num > 0 then execute immediate
  'drop table TMP_USP_PLAT_CZRYQUERY_RESULT';
  end if;
  
  select count(1) into num from user_tables where table_name = upper('TMP_USP_PLAT_CZRYQUERY_RESULT');
  if num = 0 then execute immediate
   'create global temporary table TMP_USP_PLAT_CZRYQUERY_RESULT
  (
    zclsh   VARCHAR2(64),
    rybm    VARCHAR2(64),
    jgbm    VARCHAR2(64),
    jgjc    VARCHAR2(64)
  )on commit preserve rows';
  end if;
end;
/
 declare
  num number;
begin
 select count(1) into num from user_tables where table_name = upper('TMP_USP_QUERY_ZDMLDZ_PARA');
    if num = 0 then execute immediate'
create global temporary table TMP_USP_QUERY_ZDMLDZ_PARA
(
  jgbm  VARCHAR2(22),
  zlmc  VARCHAR2(64),
  zldm  VARCHAR2(36),
  jsnum VARCHAR2(10)
)on commit preserve rows
';end if;
end;
/

相关文章

  • 2018-11-21 oracle重复提交多个表

    两种方式第一种:开始和结尾加 begin end 第二种:如果声明多个变量,每个表加结尾斜杠 / , de...

  • 表空间详解

    表空间(TABLESPACE)是ORACLE数据库中最大的逻辑结构。ORACLE数据库是由一个或多个表空间组成的。...

  • spring事务整理

    隔离级别 1、默认使用数据库的(mysql:可重复读,oracle:已提交读) 2、未提交读 会出现脏读、幻读、不...

  • 关于Mysql(5.6)的一些思考

    事物级别 MySQL 默认事物级别是可重复读;Oracle默认为读已提交 事务级别的优先级:1:读未提交 2:读已...

  • 事务----可重复读能解决幻读???

    测试可重复读 ------------------ 建表 关闭事务自动提交 SET AUTOCOMMIT =0; ...

  • Oracle 表空间

    Oracle表空间是Oracle数据库的一个逻辑划分 表空间是数据库中最大的逻辑单位 一个数据库可以有一个或多个表...

  • Oracle 表空间、用户、角色和权限基本操作

    表空间 表空间是对Oracle数据库的逻辑划分,一个数据库有一个或多个表空间,一个表空间对应着一个或多个的物理数据...

  • Oracle基础总结

    Oracle开发基础重点 Oracle一般操作 表空间 用户 表 表数据 Oracle 查询操作 单表查询 多表查...

  • Oracle中查询tablespace下所有表名

    Oracle中查询表空间下所有表名 Oracle中查询表的comments Oracle中查询表中字段的comments

  • oracle:tablespace schema block e

    oracle中存储的层次结构总结如下:数据库由一个或多个表空间组成 表空间由一个或多个数据文件组成,一个表空间包含...

网友评论

      本文标题:2018-11-21 oracle重复提交多个表

      本文链接:https://www.haomeiwen.com/subject/jvjqqqtx.html