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(學號);

相關文章
相關標籤/搜索