oracle中临时表的创建【会话级别】

来源:互联网 发布:和外国人谈恋爱知乎 编辑:程序博客网 时间:2024/06/12 00:42

一种会话级别的用法:

在当前会话中查询的结果会在临时表中存储数据,结束会话数据就被清除

1.  CREATE GLOBAL TEMPORARY TABLE tmptable  

2. ON COMMIT PRESERVE ROWS   

3.  AS  

4. SELECT *  

5.  FROM tablename  

on commit preserve rows: 定义了创建会话级临时表的方法.

 

select *from customer where state = 'CA' order by company into temp cust_in _CA;

 

将州为CA的客户按公司名称排序并保存到临时表cust_in_CA中

create global temporary table temp(临时表名)

on commit preserve rows

as

select *

from customer

where state ='CA'orderby company

原创粉丝点击