`
cary1130
  • 浏览: 197642 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

GLOBAL TEMPORARY TABLE

阅读更多

CREATE GLOBAL TEMPORARY TABLE TABLENAME (
COL1 VARCHAR2(10),
COL2 NUMBER
) ON COMMIT PRESERVE(DELETE) ROWS ;
这种临时表不占用表空间,而且不同的SESSION之间互相看不到对方的数据
在会话结束后表中的数据自动清空,如果选了DELETE ROWS,则在提交的时候即清空数据,PRESERVE则一直到会话结束

在Oracle8i中,可以创建以下两种临时表:
(1)会话特有的临时表
CREATE GLOBAL TEMPORARY <TABLE_NAME> (<column specification>)
ON COMMIT PRESERVE ROWS;

(2)事务特有的临时表
CREATE GLOBAL TEMPORARY <TABLE_NAME> (<column specification>)
ON COMMIT DELETE ROWS;
CREATE GLOBAL TEMPORARY TABLE MyTempTable
所建的临时表虽然是存在的,但是你试一下insert 一条记录然后用别的连接登上去select,记录是空的,明白了吧,我把下面两句话再贴一下:
--ON COMMIT DELETE ROWS 说明临时表是事务指定,每次提交后ORACLE将截断表(删除全部行)
--ON COMMIT PRESERVE ROWS 说明临时表是会话指定,当中断会话时ORACLE将截断表。
冲突的问题更本不用考虑.

临时表只是保存当前会话(session)用到的数据,数据只在事务或会话期间存在。

通过CREATE GLOBAL TEMPORARY TABLE命令创建一个临时表,对于事务类型的临时表,
数据只是在事务期间存在,对于会话类型的临时表,数据在会话期间存在。

会话的数据对于当前会话私有。每个会话只能看到并修改自己的数据。DML锁不会加到
临时表的数据上。下面的语句控制行的存在性。

● ON COMMIT DELETE ROWS 表名行只是在事务期间可见
● ON COMMIT PRESERVE ROWS 表名行在整个会话期间可见

可以对临时表创建索引,视图,出发器,可以用export和import工具导入导出表的
定义,但是不能导出数据。表的定义对所有的会话可见。

例如:
CREATE GLOBAL TEMPORARY TABLE TEMP_TAB1(
table_name VARCHAR2(20),
primary_key VARCHAR2(100),
field VARCHAR2(1000))
ON COMMIT PRESERVE ROWS;

CREATE GLOBAL TEMPORARY TABLE TEMP_TAB2(
table_name VARCHAR2(20),
primary_key VARCHAR2(100),
field VARCHAR2(1000))
ON COMMIT DELETE ROWS;
分享到:
评论

相关推荐

    Oracle存储过程中使用临时表

    Oracle存储过程中使用临时表 会话级临时表 事务级临时表

    Oracle事例

    sql&gt; temporary tablespace temp quota 10m on data password expire sql&gt; [account lock|unlock] [profile profilename|default]; &lt;1&gt;.查看当前用户的缺省表空间 SQL&gt;select username,default_tablespace ...

    C++编程中__if_exists与__if_not_exists语句的用法

    主要介绍了C++编程中__if_exists与__if_not_exists语句的用法,是C++中用于判断指定的标识符是否存在的基础的条件判断语句,需要的朋友可以参考下

    oracle 临时表详解及实例

    CREATE GLOBAL TEMPORARY &lt;TABLE&gt; ( &lt;column&gt; ) ON COMMIT PRESERVE ROWS;  2。事务特有的临时表 CREATE GLOBAL TEMPORARY &lt;TABLE&gt; ( &lt;column&gt; ) ON COMMIT DELETE ROWS; CREATE GLOBAL TEMPORARY TABLE ...

    wxPython 设备上下文子类(Device Context) subclasses 简介

    Table 6.1 displays a field guide to the subclasses of wx.DC and their usage. Device contexts, which are used to draw to a wxPython widget, should always be locally created, temporary objects, and ...

    acpi控制笔记本风扇转速

    - Fixed a couple table mapping issues during table load - Fixed a couple alignment issues for IA64 - Initialize input array to zero in AcpiInitializeTables - Additional parameter validation for ...

    微软内部资料-SQL性能优化3

    Another type of table lock is a schema stability lock (Sch-S) and is compatible with all table locks except the schema modification lock (Sch-M). The schema modification lock (Sch-M) is incompatible ...

    最全的oracle常用命令大全.txt

    where c.owner = upper('&table_owner') and c.table_name = upper('&table_name') and c.owner = cc.owner and c.constraint_name = cc.constraint_name order by cc.position; 8、存储函数和过程 查看函数...

    深度探索模C++对象模型PDF

    6.3 临时性对象(Temporary Objects) 临时性对象的迷思(神话、传说) 第7章 站在对象模型的类端(On the Cusp of the Object Model) 7.1 Template Template的“具现”行为(Template Instantiation) Template的...

    深度探索C++对象模型 超清版

    6.3 临时性对象(Temporary Objects) 临时性对象的迷思(神话、传说) 第7章 站在对象模型的类端(On the Cusp of the Object Model) 7.1 Template Template的“具现”行为(Template Instantiation) Template的...

    uboott移植实验手册及技术文档

    实验三 移植U-Boot-1.3.1 实验 【实验目的】 了解 U-Boot-1.3.1 的代码结构,掌握其移植方法。 【实验环境】 1、Ubuntu 7.0.4发行版 2、u-boot-1.3.1 3、FS2410平台 4、交叉编译器 arm-softfloat-linux-gnu-...

    《深度探索C++对象模型》(Stanley B·Lippman[美] 著,侯捷 译)

    6.3 临时性对象(Temporary Objects) 临时性对象的迷思(神话、传说) 第7章 站在对象模型的类端(On the Cusp of the Object Model) 7.1 Template Template的“具现”行为(Template Instantiation) Template的...

    qemu-0.13.0(编译过全处理器支持)

    -snapshot write to temporary files instead of disk image files -m megs set virtual RAM size to megs MB [default=128] -mem-path FILE provide backing storage for guest RAM -k language use keyboard ...

    Qemu-1.0.1 for windows

    -snapshot write to temporary files instead of disk image files -m megs set virtual RAM size to megs MB [default=128] -mem-path FILE provide backing storage for guest RAM -k language use keyboard ...

    Turbo C 2.00[DISK]

    TABLE OF CONTENTS ----------------- 1. How to Get Help 2. Installation 3. Important Notes 4. Corrections to the Manuals 5. Additional Notes 6. Notes for Turbo Prolog Users 7. Files on the Disks...

    Turbo C 2.01[DISK]

    TABLE OF CONTENTS ----------------- 1. How to Get Help 2. Installation 3. Important Notes 4. Additional Notes 5. Notes for Turbo Prolog Users 6. Files on the Disks 1. HOW TO GET HELP --------...

    BobBuilder_app

    I deferred from testing the get test over 100 million record as it would require a huge array in memory to store the Guid keys for finding later, that is why there is a NT (not tested) in the table. ...

    微软内部资料-SQL性能优化2

    The user address space is where application code, global variables, per-thread stacks, and DLL code would reside. The system address space is where the kernel, executive, HAL, boot drivers, page ...

    php.ini-development

    ;;;;;;;;... 1.... 2.... 3.... 4.... 5.... 6.... The syntax of the file is extremely simple.... Section headers (e.g.... at runtime.... There is no name validation.... (e.g.... previously set variable or directive (e.g....

    精通websphere MQ

    目录.................................................................................................................................2 内容提要...........................................................

Global site tag (gtag.js) - Google Analytics