db2表字段修改
1:刪除字段非空屬性
alter table XXX alter column XXX drop not null
2:添加字段非空屬性
alter table XXX alter column XXX set not null
3:添加一個新字段
alter table XXX add column XXXX varchar(100)
4:刪除一個字段
alter table XXX drop column XXX
5:增加字段的長度
alter table XXX alter column XXX set data type varchar(100)
注意:
1:不允許修改字段的名稱(只能先刪除,再添加)。
2:不允許減小字段的長度。
3:不允許修改字段類型(如把 Integer 修改成 varchar)。
4:如果必須修改上三條中的情況,只能重新建表(第一條有簡單方法)。