提问,插入数据之后,COMMIT,数据是否一定会在表里呢?

回答 一定会在。我认为没有错

回答 可能会在。也没有错  → 没在就一定是被删了,那么有一种表,会在Commit时,清空所有数据。

刚才说的那种就是Gobal Temporary Table,临时表。

当然人为定义创建规定当然也可以,各有好处,自己判断。

ON COMMIT DELETE ROWS;   →在COMMIT的时候,删除所有数据

如果没有COMMIT,数据会不会留下来呢?Oracle想到了,临时表中的数据可以在session中断时被自动drop,如当用户退出或者Session异常中断.

以下为转载内容:

From:http://hwhuang.iteye.com/blog/551864

From:http://www.oracle-base.com/articles/8i/TemporaryTables.php 
Applications often use some form of temporary data store for processes that are to complicated to complete in a single pass. Often, these temporary stores are defined as database tables or PL/SQL tables. In Oracle 8i, the maintenance and management of temporary tables can be delegated to the server by using Global Temporary Tables. 
=>应用者经常需要用临时数据组成的一些表,store一些用单一的方式很难达到的过程。通常,这些临时性stores被定义为数据库表或pl/sql 表。在oracle 8i,临时表的维护和管理通过用全局临时表来委派给server.

Creation of Global Temporary Tables 
The data in a global temporary table is private, such that data inserted by a session can only be accessed by that session. The session-specific rows in a global temporary table can be preserved for the whole session, or just for the current transaction. The ON COMMIT DELETE ROWS clause indicates that the data should be deleted at the end of the transaction. 
=>创建全局临时表 
在全局临时表中的数据是私有的,在一个session中插入的数据只能在同一个session中被获取。在全局临时表中指定session里的行被保存在整个session或者是当前的transaction中。on commit delete rows语句说明在session中的数据应该在transaction结束时被delete.例如: 

Java代码  
  1. CREATE GLOBAL TEMPORARY TABLE my_temp_table (
  2. column1  NUMBER,
  3. column2  NUMBER
  4. ) ON COMMIT DELETE ROWS;

In contrast, the ON COMMIT PRESERVE ROWS clause indicates that rows should be preserved until the end of the session. 
=>相反,on commit preserve rows 语句指出直至session结束data应该保存在内存中。

Java代码  
  1. CREATE GLOBAL TEMPORARY TABLE my_temp_table (
  2. column1  NUMBER,
  3. column2  NUMBER
  4. ) ON COMMIT PRESERVE ROWS;

Miscellaneous Features 
If the TRUNCATE statement is issued against a temporary table, only the session specific data is trucated. There is no affect on the data of other sessions. 
=>如果truncate一个临时表时,只是对当前session里的数据trucate,而对其它session里的数据没有任何影响。  
Data in temporary tables is automatically delete at the end of the database session, even if it ends abnormally. 
=>即使session以不正常结束,临时表中的数据也会在session结束时候被自动删除。  
Indexes can be created on temporary tables. The content of the index and the scope of the index is that same as the database session. 
Views can be created against temporary tables and combinations of temporary and permanent tables. 
=>index能被创建在临时表上,索引的内容和范围与session的一样。view能被创建在临时表,以及临时表与永久表的结合表上。(这里所谓结合表,应该是联合查询取得的数据表)  
DML locks are not acquired on the data of the temporary tables. The LOCK statement has no effect on a temporary table because each session has its own private data. 
=>DML锁对于临时表的数据来说没有影响,因为每个Session都有它私有的数据。  
Temporary tables can have triggers associated with them. 
Export and Import utilities can be used to transfer the table definitions, but no data rows are processed. 
=>临时表有trigger与之关联。导入,导出功能也可以放在表定义的转换,但是没有数据。

Specify GLOBAL TEMPORARY to indicate that the table is temporary and that its definition is visible to all sessions. The data in a temporary table is visible only to the session that inserts the data into the table. 
特定全局临时表---对于所有的Session都可见,并且临时表中的数据只对插入数据到表中的Session可视。 
Restrictions: 
=>局限性:  
1.Temporary tables cannot be partitioned, index-organized, or clustered. 
=>临时表不能被分区,索引化和群集。  
2.You cannot specify any referential integrity (foreign key) constraints on temporary tables. 
=>不能在临时表上指定任何完整性约束。  
3.Temporary tables cannot contain columns of nested table or varray type. 
=>临时表中不能包含嵌套表或变量数组之类的列。  
4.You cannot specify the following clauses of the LOB_storage_clause: TABLESPACE, storage_clause, LOGGING or NOLOGGING, MONITORING or NOMONITORING, or LOB_index_clause. 
=>不能指定如下clause:TABLESPACE, storage_clause, LOGGING or NOLOGGING, MONITORING or NOMONITORING, or LOB_index_clause.  
Parallel DML and parallel queries are not supported for temporary tables. (Parallel hints are ignored. Specification of the parallel_clause returns an error.) 
=>相应的DML和queries也不支持临时表。  
5.You cannot specify the segment_attributes_clause, nested_table_storage_clause, or parallel_clause. 
=>同时在临时表上指定segment_attributes_clause, nested_table_storage_clause, or parallel_clause。 6.Distributed transactions are not supported for temporary tables. 
=>临时表也不支持分布式事务。 
以下是一个Global Temporary Table的实例:

Java代码  
  1. create global temporary table T_FORM4_POL_CHG_TMP
  2. (
  3. POLICY_ID     NUMBER(10) not null,
  4. CHANGE_ID     NUMBER(10),
  5. SERVICE_ID    NUMBER(10),
  6. FINISH_TIME   DATE,
  7. CASE_ID       NUMBER(10),
  8. WITHDRAW_TIME DATE,
  9. CHANGE_STATUS VARCHAR2(2)
  10. );

临时表的介绍: 
Data in a temporary table is private to the session. Each session can only see and modify its own data. 
=>在临时表中的数据只是对当前session可见,每个session仅能访问和修改属于它的数据。  
DML statements on temporary tables do not generate redo logs for the data changes. However, undo logs for the data and redo logs for the undo logs are generated. Data from the temporary table is automatically dropped in the case of session termination, either when the user logs off or when the session terminates abnormally such as during a session or instance crash. 
=>对临时表的DML操作,不会对数据变化生成重做日志。然而,可以生成对数据的撤销日志和对撤销日志的重做日志。临时表中的数据可以在session中断时被自动drop,如当用户退出或者Session异常中断.  
You can create indexes for temporary tables using the CREATE INDEX statement. Indexes created on temporary tables are also temporary, and the data in the index has the same session or transaction scope as the data in the temporary table.

You can create views that access both temporary and permanent tables. You can also create triggers on temporary tables. 
=>你能在临时表上创建索引,在临时表上的索引也是临时的,在索引上的数据同临时表中的数据一样,在相同的session或事务中。同时,也能在临时表上创建视图和触发器。

Segment Allocation 段的分配 
Temporary tables use temporary segments. Unlike permanent tables, temporary tables and their indexes do not automatically allocate a segment when they are created. Instead, segments are allocated when the first INSERT (or CREATE TABLE AS SELECT) is performed. This means that if a SELECT, UPDATE, or DELETE is performed before the first INSERT, then the table appears to be empty. 
=>临时表用临时段。与永久表不同,临时表和属于它的索引在被创建时候,是无法自动分配段空间。取而代之,在第一次插入数据的时候,段空间才会被分配。换句话说,在Select,Update,delete执行前,必须做insert操作,因为那时数据表都为空。  
You can perform DDL statements (ALTER TABLE, DROP TABLE, CREATE INDEX, and so on) on a temporary table only when no session is currently bound to it. A session gets bound to a temporary table when an INSERT is performed on it. The session gets unbound by a TRUNCATE, at session termination, or by doing a COMMIT or ABORT for a transaction-specific temporary table. 
=>仅当临时表不与临时表关联时候,才可以对它之行DDL操作(ALTER TABLE,DROP TABLE,CREATE INDEX等操作)。  
Temporary segments are deallocated at the end of the transaction for transaction-specific temporary tables and at the end of the session for session-specific temporary tables. 
=>在Session结束或者Transaction结束时候临时段才会被收回。

Oracle 临时表 (Gobal Temporary Table)相关推荐

  1. oracle 查询temporary table,Oracle临时表(Temporary Table)

    GLOBAL TEMPORARY代表全局临时表 临时表的元数据存储在数据字典里面 只当第一条DML命令发生的时候才为这张表的段分配空间 临时表数据的可见范围应该是会话级别或是事务级别的 会话或者事务级 ...

  2. 简单聊聊MySQL临时表(TEMPORARY TABLE)

    目录什么的也不需要 一.什么是临时表 二.临时表有哪些类型 1.内部临时表: 2.外部临时表: 三.对外部临时表说两句 四.执行验证 一.什么是临时表 MySQL临时表在很多场景中都会用到,MySQL ...

  3. mysql temporary_MySQL内部临时表(Internal Temporary Table)

    当某些SQL命令在MySQL数据库中被执行的时候,它可能需要先创建一些内部的临时表来完成比较复杂的排序或分组查询.MySQL的临时表分为 in-memory 和 on-disk 两种. 如有可能,My ...

  4. Oracle - 临时表(GLOBAL TEMPORARY TABLE)

    http://aofengblog.blog.163.com/blog/static/6317021200951664351836/ Oracle - 临时表(GLOBAL TEMPORARY TAB ...

  5. oracle会话临时表会造成死锁,Oracle Temporary Tables(Oracle 临时表)

    Oracle Temporary Tables(Oracle 临时表) 1. 建立临时表语法 A.ON COMMIT DELETE ROWS 定义了建立事务级临时表的方法 CREATE GLOBAL ...

  6. java temporary_临时表temporary table

    临时表temporary table =========================================================== 作者: xsb(http://xsb.it ...

  7. 临时表temporary table

    8i以上版本. Oracle 的临时表与MSSQL的不同,临时表需要先创建,不建议在运行时使用DDL语句创建! 临时表可以看作是一张普通的物理表,在其上可以建索引.建视图,建触发器等!但它的数据是会话 ...

  8. mysql中temporary_MySQL的复制和临时表(Temporary Table)

    当你创建临时表的时候,你可以使用temporary关键字.如: create temporary table tmp_table(name varchar(10) not null,passwd ch ...

  9. [Oracle] 中的Temporary tablespace的作用

    临时表空间主要用途是在数据库进行排序运算[如创建索引.order by及group by.distinct.union/intersect/minus/.sort-merge及join.analyze ...

最新文章

  1. Oracle 分析及动态采样
  2. 计算机的主存储器可以分为哪两类,2017年计算机应用基础模拟试题「答案」(2)...
  3. test - delete category 060 in X3C - R3MATCLASS and perform customizing download
  4. 字节教育大裁员:有员工赔了一套首付款!
  5. JavaScript学习(三十三)—事件对象常用的属性和方法
  6. 一个文件版的名片管理系统(Python3)
  7. 物联网与嵌入式系统的关系
  8. Oracle中的SQL函数(全)
  9. Hulu是什么?中国也有了?
  10. [从头读历史] 第276节 诗经 陈风
  11. 实验一-波士顿房价预测
  12. Elasticsearch集群原理
  13. java geohash_GitHub - GongDexing/Geohash: GeoHash是目前比较主流实现位置服务的技术,用最简洁的Java实现GeoHash算法...
  14. 简单认识顺序表的基本操作
  15. Win7文件夹属性里的自定义选项卡丢失
  16. 【C++】C++数组初始化方法
  17. 以太网_什么是以太网
  18. c语言食堂菜谱管理系统,基于C语言的食堂菜谱管理系统
  19. 英语学习详细笔记(六)比较级
  20. /mnt/hgfs为空

热门文章

  1. 计算机视觉学习路线—计算机视觉入门必读的20本书
  2. 第四平方和定理,用c语言实现
  3. 软件工程 个人学习笔记(第三章)
  4. 坐标系旋转与点旋转的变换公式
  5. Python几种常用的数据导入方法
  6. 大腿根部发黑怎么样白,变白方法
  7. python二级题库 第四套 附刷题软件
  8. 批量文件压缩下载(zip)
  9. 大数据学习之javaAPI远程操作hadoop
  10. building workspace问题