db2 建立临时表、复制表结构、表数据

复制表结构:create table t1 like petition_basic_info;session

赋值表数据:spa

insert into tablea(col1,col2) select col1,col2 from tablea where col1=xx,col2=yy

删除表数据:delete t1;code

删除表:drop table t1;blog

--------------------------------------------------------------
索引

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

老是提示表的记录长度太长,此语句或有帮助it

db2 list tablespaces show detail

第一步:先建立临时表空间:io

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

第二步:建立临时表:class

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(学号);

相关文章
相关标签/搜索