db2中表的一些常用操作语句。

来源:互联网 发布:娃哈哈波士顿矩阵分析 编辑:程序博客网 时间:2024/06/04 23:19
1.表中添加字段:
alter table 表名 add column 字段名 字段类型
2.给表中的字段重新命名:
altet table 表名 rename column 原字段名 to 现字段名; 
3.修改表名:
rename table  旧表名  to 新的表名;
4.添加联合主键:
alter table 表名 add constraint  联合主键名称   primary key(主键1,主键2);
5.删除表中的主键:
alter table 表名 drop primary;
6.修改表中的字段类型或者长度:
       alter table 表名 alter column 字段名 set data type 字段类型(或字段长度);
7.添加索引
create index 索引名称 on 表名(字段名称);//给表中的某个字段加上索引(索引名称要见名知意,index_XX)
8.重构表
        db2 reorg table 表名;
9.字段加上注释
        comment on column 表名.字段名   is   '注释名'
。。。。。

0 0
原创粉丝点击