Oracle临时表(即:Oracle 全局临时表)的语法
2015-12-09 16:02
489 查看
摘自:
http://docs.oracle.com/cd/E11882_01/server.112/e41084/statements_7002.htm#SQLRF01402
例子:
The following statement creates a temporary table today_sales for use by sales representatives in the sample database.
Each sales representative session can store its own sales data for the day in the table. The temporary data is deleted at the end of the session.
Specify GLOBAL TEMPORARY to indicate that the table is temporary and that its definition is visible to all sessions with appropriate privileges.
The data in a temporary table is visible only to the session that inserts the data into the table.
When you first create a temporary table, its table metadata is stored in the data dictionary, but no space is allocated for table data.
Space is allocated for the table segment at the time of the first DML operation on the table.
The temporary table definition persists in the same way as the definitions of regular tables,
but the table segment and any data the table contains are either session-specific or transaction-specific data.
You specify whether the table segment and data are session- or transaction-specific with the ON COMMIT keywords.
You can perform DDL operations (such as ALTER TABLE, DROP TABLE, CREATE INDEX) on a temporary table only when no session is bound to it.
A session becomes bound to a temporary table by performing an INSERT operation on the table.
A session becomes unbound to the temporary table by issuing a TRUNCATE statement or at session termination,
or, for a transaction-specific temporary table, by issuing a COMMIT or ROLLBACK statement.
http://docs.oracle.com/cd/E11882_01/server.112/e41084/statements_7002.htm#SQLRF01402
例子:
The following statement creates a temporary table today_sales for use by sales representatives in the sample database.
Each sales representative session can store its own sales data for the day in the table. The temporary data is deleted at the end of the session.
CREATE GLOBAL TEMPORARY TABLE today_sales ON COMMIT PRESERVE ROWS AS SELECT * FROM scott.emp where rownum<2;
DELETE ROWS 的含义: DELETE ROWS Specify DELETE ROWS for a transaction-specific temporary table. This is the default. Oracle Database will truncate the table (delete all its rows) after each commit.
PRESERVE ROWS 的含义 PRESERVE ROWS Specify PRESERVE ROWS for a session-specific temporary table. Oracle Database will truncate the table (delete all its rows) when you terminate the session.
Specify GLOBAL TEMPORARY to indicate that the table is temporary and that its definition is visible to all sessions with appropriate privileges.
The data in a temporary table is visible only to the session that inserts the data into the table.
When you first create a temporary table, its table metadata is stored in the data dictionary, but no space is allocated for table data.
Space is allocated for the table segment at the time of the first DML operation on the table.
The temporary table definition persists in the same way as the definitions of regular tables,
but the table segment and any data the table contains are either session-specific or transaction-specific data.
You specify whether the table segment and data are session- or transaction-specific with the ON COMMIT keywords.
You can perform DDL operations (such as ALTER TABLE, DROP TABLE, CREATE INDEX) on a temporary table only when no session is bound to it.
A session becomes bound to a temporary table by performing an INSERT operation on the table.
A session becomes unbound to the temporary table by issuing a TRUNCATE statement or at session termination,
or, for a transaction-specific temporary table, by issuing a COMMIT or ROLLBACK statement.
相关文章推荐
- Oracle创建表空间和用户语句
- oracle配置数据源的文件 相关配置
- 【Oracle】--PL/SQL导入Oracle sql脚本"傻瓜教程"
- oracle 错误码查看命令oerr ora及常用错误码总结--不断更新
- Oracle查看锁表与解锁方法
- Windows下Oracle 10g instant client安装配置
- oracle多表查询优化
- oracle 分析函数
- Jmeter之JDBC Request使用方法(oracle)
- oracle 创建dblink
- 【原创】Oracle实现PGSQL的generate_series
- Oracle实现POSTGRESQL的generate_series功能
- Oracle在更改机器名后服务无法启动的解决方法
- 甲骨文为树莓派版(ARM)Java提供支持
- Oracle之SQL基础--约束
- oracle db_link的使用说明
- plsql 远程访问Oracle报错
- Oracle中如何获取系统当前时间
- Oracle数据导入导出图解(图文并茂)
- 在Linux下编译proc程序报错:fcc-f-02104 unable to connect to oracle