创建db2临时表 详解

来源:互联网 发布:淘宝买家总是退货 编辑:程序博客网 时间:2024/04/30 00:38

第一步:先创建临时表空间:

create user temporary tablespace test
pagesize 4 k managed by system
using ('[curdir]\temp');

第二步:创建临时表:

declare global temporary table t1
like student
on commit preserve rows not logged in test;

如果不加上  on commit preserve rows 当insert临时表提交之后临时表里的数据会自动删除掉

第三步:插入数据

 insert into session.t1
select * from student

第四步:查询数据

select * from  session.t1 where 学号 = 081103;

第五步:创建索引,提高速度

create index session.t1index on session.t1(学号);

参考文章http://gong-10140.iteye.com/blog/1593660

原创粉丝点击