DB2数据库常用命令

时间:2022-02-03 03:25:51
1.数据库表增加、修改字段 ALTER TABLE itsm_cti ADD CI_TABLE varchar(30) 修改数据库字段  alter table smp_runtime_db2 alter  last_backup set data type varchar(20); 
alter table itsm_incident drop column deparment_id
http://www.cnblogs.com/freshman0216/archive/2008/08/15/1268316.html
连接至数据库:
connect to <db-name> user <username> using password
2.DB2数据库中的数据操作(导入导出)export to [path(例:D:"TABLE1.ixf)] of ixf select [字段(例: * or col1,col2,col3)] from TABLE1;export to [path(例:D:"TABLE1.del)] of del select [字段(例: * or col1,col2,col3)] from TABLE1;

导入表的数据

import from [path(例:D:"TABLE1.ixf)] of ixf insert into TABLE1

load from [path(例:D:"TABLE1.ixf)] of ixf insert into TABLE1;

3.导出数据库中所有表http://blog.csdn.net/zero_plus/article/details/6169520

d
b2look -d itsmV6 -e -i -db2inst1 -w db2inst1 -o itsm.ddl
4.查询数据库中表名匹配syscat.tables
select * from syscat.tables where tabname like '%BASE%';
5.重组表
su - db2inst1
之前需db2 connect to ynv6td user db2inst1 using db2inst1
db2 reorg table itsm_ci_computer
6.alter table itsm_portal_widget_user drop primary key;
7.select * from itsm_incident fetch first 10 rows only;