ITPub博客

首页 > 数据库 > Oracle > oracle临时表

oracle临时表

原创 Oracle 作者:tolilong 时间:2013-12-22 14:37:53 0 删除 编辑

C:\Users\wlcsp>sqlplus / as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on 星期日 12月 22 09:52:41 2013

Copyright (c) 1982, 2010, Oracle.  All rights reserved.


连接到:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> show  user
USER 为 "SYS"

SQL> create global temporary table tt1(id int,name varchar2(20)) on commit prese
rve rows;

表已创建。

on commit preserve rows;表示创建SESSION级别

SQL> create global temporary table tt2(id int,name varchar2(20)) on commit delet
e rows;

on commit delete rows;  表示创建TRANSACTION级别.

表已创建。

SQL> select object_name,temporary from dba_objects where object_name in('TT1','T
T2');

OBJECT_NAME          TE
-------------------- --
TT2                  Y
TT1                  Y

##########################################################################################
tt1测试:
SQL> insert into tt1 values(1,2);

已创建 1 行。

SQL> commit;

提交完成。

SQL> select * from tt1;

        ID NAME
---------- ---------------------------------------
         1 2
session 1 insert一条记录后,select有记录。

SQL> select * from tt1;

未选定行
session 2 insert一条记录后,select没有记录。

########################################################################################
session表
SQL> select * from tt1;

        ID NAME
---------- ----------------------------------------
         1 2

SQL> create index tt1_index on tt1(id);
create index tt1_index on tt1(id)
                          *
第 1 行出现错误:
ORA-14452: 试图创建, 变更或删除正在使用的临时表中的索引

断开重新连接后,可以创建index
C:\Users\wlcsp>sqlplus / as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on 星期日 12月 22 14:33:31 2013

Copyright (c) 1982, 2010, Oracle.  All rights reserved.


连接到:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> create index tt1_index on tt1(id);

索引已创建。

############################################################################
transaction表
C:\Users\wlcsp>sqlplus / as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on 星期日 12月 22 14:33:22 2013

Copyright (c) 1982, 2010, Oracle.  All rights reserved.


连接到:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> select * from tt2;

未选定行

SQL> insert into tt2 values(1,2);

已创建 1 行。

SQL> create index tt2_index on tt2(id);

索引已创建。

用户可以创建同时访问永久表(permanent table)与临时表(temporary table)的视图。用户还可以在临时表上创建触发器(trigger)。

Oracle 提供的工具可以导出/导入(export/import)临时表的定义,但是无法导出其中的数据,在工具中使用 ROWS 子句也是无效的。同样用户可以复制(replicate)临时表的定义,但不能复制其数据

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/24237320/viewspace-1063996/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2010-07-13

  • 博文量
    406
  • 访问量
    1208666