1、cursor 不能放在 from 子句中, 使用不方便啊!2、GLOBAL 临时表 在多个用户同时操作时会否引起冲突, 或者永远不对 GLOBAL 临时表 commit ,能避免冲突吗?
oracle也有临时表,不过是一个表,创建方式为:create global temporary table ...,通常是创建若干字符字段,若干数字字段,若干日期字段...,要对用户授权,能插入临时数据.一般是创建一个别名,方便访问,每个session只能访问自己的数据,这些数据不放在硬盘上,临时数据的生命期通常是一个事务(好象还可以以一个DML语句为一个生命周期)
我搜索到的答案: 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.A temporary table has a definition that persists the same as the definitions of regular tables, but it contains either session-specific or transaction-specific data. You specify whether the data is session- or transaction-specific with the ON COMMIT keywords.ON COMMIT The ON COMMIT clause is relevant only if you are creating a temporary table. This clause specifies whether the data in the temporary table persists for the duration of a transaction or a session.DELETE ROWS Specify DELETE ROWS for a transaction-specific temporary table (this is the default). Oracle will truncate the table (delete all its rows) after each commit.PRESERVE ROWS Specify PRESERVE ROWS for a session-specific temporary table. Oracle will truncate the table (delete all its rows) when you terminate the session.谢谢各位!
CREATE GLOBAL TEMPORARY TABLE
或者永远不对 GLOBAL 临时表 commit ,能避免冲突吗?
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.A temporary table has a definition that persists the same as the definitions of regular tables, but it contains either session-specific or transaction-specific data. You specify whether the data is session- or transaction-specific with the ON COMMIT keywords.ON COMMIT
The ON COMMIT clause is relevant only if you are creating a temporary table. This clause specifies whether the data in the temporary table persists for the duration of a transaction or a session.DELETE ROWS
Specify DELETE ROWS for a transaction-specific temporary table (this is the default). Oracle will truncate the table (delete all its rows) after each commit.PRESERVE ROWS
Specify PRESERVE ROWS for a session-specific temporary table. Oracle will truncate the table (delete all its rows) when you terminate the session.谢谢各位!