- 浏览: 450031 次
- 性别:
- 来自: 上海
文章分类
最新评论
-
鱼里的yeol:
正在学习EJB 感觉有些吃力
Ejb3学习之二----Ejb3的Ejb Bean类型介绍 -
phoenix5870:
默认就是singleton的。
Spring中的Singleton模式和Java中的Singleton模式 -
jhys7s8jd:
pdf打印机下载 无水印http://www.onlinedo ...
PDFCreate工具的使用 -
wang371134086:
:e vil:
浅谈Struts2中的拦截器实现责任链模式 -
liu765023051:
亲,local与remote有什么区别呢
EJB学习之三---Local和Remote接口
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.例如:
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应该保存在内存中。
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的实例:
临时表的介绍:
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结束时候临时段才会被收回。
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.例如:
CREATE GLOBAL TEMPORARY TABLE my_temp_table ( column1 NUMBER, column2 NUMBER ) 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应该保存在内存中。
CREATE GLOBAL TEMPORARY TABLE my_temp_table ( column1 NUMBER, column2 NUMBER ) 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的实例:
create global temporary table T_FORM4_POL_CHG_TMP ( POLICY_ID NUMBER(10) not null, CHANGE_ID NUMBER(10), SERVICE_ID NUMBER(10), FINISH_TIME DATE, CASE_ID NUMBER(10), WITHDRAW_TIME DATE, CHANGE_STATUS VARCHAR2(2) );
临时表的介绍:
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的Hash Join之探究整理
2012-04-08 15:48 11383Hash join算法原理 自从or ... -
Oracle Event 10046
2012-03-29 23:17 1637下面是一个10046的例子,可以用来分析具体的一些sql执行计 ... -
使用SQL_TRACE进行数据库诊断
2012-03-29 23:08 1009From:http://www.eygle.com/archi ... -
Oracle索引之B-Tree和Bitmap索引对比
2012-03-23 18:32 2359B树索引是所有大型关系 ... -
Oracle性能优化五大工具介绍
2012-03-23 15:55 1593本文介绍了Oracle性能优化工具Oracle数据库在线数据字 ... -
Oracle事物处理中回滚段容量的问题
2012-03-23 15:33 1634在执行大事务时,有时oracle会报出如下的错误: ORA- ... -
Oracle 中条件分歧总结
2011-06-01 23:17 1345Oracle 中条件分歧总结: * Decode * IF ... -
ORACLE CASE WHEN 及 SELECT CASE WHEN的用法
2011-06-01 23:07 2348转载:http://blog.csdn.net/songsen ... -
View的作用
2010-11-11 00:53 3198这篇文章重要讲述下关 ... -
Oracle For Update 行锁
2010-11-08 23:43 1993转自:http://hi.baidu.com/mcj0127/ ... -
Mysql的存储引擎:InnoDB和MyISAM区别
2010-10-05 02:25 1376InnoDB和MyISAM是许多人在 ... -
SSMAを活用してMySQL/AccessからSQL Server/Azureへマイグレーション
2010-09-10 23:03 2345作者 Abel Avram , 翻訳者 (株)ネクストスケープ ... -
Oracle 嵌套事务与自治事务思考
2010-04-22 21:35 6257关键字 嵌套事务和自治事务的概念 嵌套事务的使用 ... -
Oracle中Cursor介绍
2010-04-21 22:09 1734关键字 概念 类型 异常处理 一 概念 游标是SQL ... -
Oracle 10g 中动态性能视图
2010-04-16 19:18 2057动态性能视图用于记录当前例程的活动。启动例程时,oracle会 ... -
Oracle 和 Sql Server中日期的显示问题
2010-03-10 02:01 2880在日常的项目中,经常遇见User需要显示不同的日期格式。当然, ... -
Oracle中RowNum的用法
2010-02-08 22:05 1810ROWNUM,是一种伪列,它根据特定记录返回一个序列化的数字。 ... -
ORACLE 分析函数解析
2010-01-17 21:29 1357分析函数是oracle 8.1.6中就引入的一个全新的概念,为 ... -
ORACLE LOB大对象处理
2010-01-16 21:42 2456ORACLE LOB大对象处理 主要是用来存储大量数据的数据库 ... -
DUMP用法
2010-01-16 09:13 1866一 DUMP():查看表中列在datafile中的存储内容,它 ...
相关推荐
CREATE GLOBAL TEMPORARY TABLE temp_table ( column1 datatype, column2 datatype, ... ) ON COMMIT DELETE ROWS; ``` 这里的`ON COMMIT DELETE ROWS`选项表示当事务提交时,表中的所有数据将被删除。 2. *...
- 使用`CREATE GLOBAL TEMPORARY TABLE`语句创建临时表。 - 可以通过`ON COMMIT`子句来定义数据的生命周期,即数据在何时被清除。 #### 三、创建临时表 **1. 基本语法:** ```sql CREATE GLOBAL TEMPORARY TABLE ...
sql> create global temporary table xay_temp as select * from xay on commit preserve rows / on commit delete rows; ``` **解析**: - `create global temporary table`: 创建全局临时表。 - `on commit ...
CREATE GLOBAL TEMPORARY TABLE Table_Name (Col1 Type1, Col2 Type2...) ON COMMIT PRESERVE ROWS; ``` 例如: ```sql CREATE GLOBAL TEMPORARY TABLE Student (Stu_id NUMBER(5), Class_id NUMBER(5), Stu_...
1. **创建临时表**: 创建临时表的语法与创建普通表类似,但需在表名前加上关键字"GLOBAL TEMPORARY TABLE"。例如: ```sql CREATE GLOBAL TEMPORARY TABLE temp_table ( column1 datatype, column2 datatype, ....
CREATE GLOBAL TEMPORARY TABLE Table_Name ( Col1 Type1, Col2 Type2 ) ON COMMIT PRESERVE ROWS; ``` 示例: ```sql CREATE GLOBAL TEMPORARY TABLE Student ( Stu_id NUMBER(5), Class_id NUMBER(5), Stu_...
DECLARE GLOBAL TEMPORARY TABLE SESSION.t_projects AS ( full select ) DEFINITION ONLY ON COMMIT PRESERVE ROWS NOT LOGGED WITH REPLACE IN TABLESPACE apptemps; ``` 最后,我们提到了几个与时间相关的内置...
CREATE GLOBAL TEMPORARY TABLE 语句可以用于创建临时表。例如,CREATE GLOBAL TEMPORARY TABLE ... 12. Free space after delete 在删除数据后,Oracle 9i 数据库中会留下空闲空间。这个空闲空间可以用于将来插入...
本文将详细介绍如何在Oracle中创建临时表,并探讨其应用场景以及两种主要类型的临时表:全局临时表(Global Temporary Table)与局部临时表(Local Temporary Table)的区别及其使用方法。 #### 二、Oracle临时表...
CREATE GLOBAL TEMPORARY TABLE TABLE_NAME (COUMNS …) AS SELECT … FROM TABLE ON COMMIT DELETE ROWS; ``` 2. **会话级临时表**: 使用`ON COMMIT PRESERVE ROWS`选项创建。在这种情况下,数据会在当前...
CREATE GLOBAL TEMPORARY TABLE table_name (column_specification) ON COMMIT PRESERVE ROWS; ``` 2. 事务级临时表: ```sql CREATE GLOBAL TEMPORARY TABLE table_name (column_specification) ON COMMIT DELETE ...
- **全局临时表**(Global Temporary Table, GGT):不同于会话级临时表,全局临时表可以在整个数据库实例内共享,并且可以在提交或回滚事务后保留数据,直到下一次插入新数据覆盖为止。 #### 四、临时表的创建与...
CREATE GLOBAL TEMPORARY TABLE table (column datatype [DEFAULT expr] [{ NULL | NOT NULL}], [column datatype [DEFAULT expr] [ {NULL | NOT NULL} ]...) ON COMMIT {DELETE | PRESERVE} ROWS; ``` 其中,`ON...
CREATE GLOBAL TEMPORARY TABLE temp_table ( column1 datatype1, column2 datatype2, ... columnN datatypeN ) ON COMMIT PRESERVE ROWS; INSERT INTO temp_table SELECT * FROM ( SELECT column1, column2, ...
CREATE GLOBAL TEMPORARY TABLE temp_table ( column1 datatype, column2 datatype, ... ) ON COMMIT DELETE ROWS; ``` 其中`ON COMMIT DELETE ROWS`表示在事务提交后删除临时表中的所有行,另一种选项是`ON ...
CREATE GLOBAL TEMPORARY TABLE Student ( Stu_id NUMBER(5), Class_id NUMBER(5), Stu_Name VARCHAR2(8), Stu_Memo VARCHAR2(200) ) ON COMMIT PRESERVE ROWS; ``` 2. **事务级临时表**:与会话级临时表...
create global temporary table Student ( Stu_id Number(5), Class_id Number(5), Stu_Name Varchar2(8), Stu_Memo varchar2(200) ) on commit preserve rows; ``` - **On Commit Delete Rows**:当事务...
- **创建**:创建事务临时表的命令通常类似于`CREATE GLOBAL TEMPORARY TABLE Temp_user (ID NUMBER(12) PRIMARY KEY, name VARCHAR2(10))`。默认情况下,如果没有明确指定,Oracle将创建的临时表视为事务临时表。...
创建这类临时表的命令格式为 `CREATE GLOBAL TEMPORARY TABLE ... ON COMMIT DELETE ROWS`。这类表在事务结束(通常在提交COMMIT后)时会自动清空其内容。这意味着在同一个事务内的多次操作可以共享数据,而其他...
CREATE GLOBAL TEMPORARY TABLE Temp_User ( ID NUMBER(12) PRIMARY KEY, Name VARCHAR2(10) ) ON COMMIT DELETE ROWS; ``` 上述SQL语句创建了一个事务临时表`Temp_User`,其中`ON COMMIT DELETE ROWS`指定了...