db2數(shù)據(jù)庫新增字段 db2增字段?
db2增字段?第一次創(chuàng)建表時,會創(chuàng)建一個自遞增字段。語法:connect to samplescreen table tutest(FID BIGINT NOT NULL GENERATED ALWA
db2增字段?
第一次創(chuàng)建表時,會創(chuàng)建一個自遞增字段。語法:connect to samplescreen table tutest(FID BIGINT NOT NULL GENERATED ALWAYS AS IDENTITY(從1開始,遞增1,沒有緩存),F(xiàn)Name varchar(10))connect reset第二種方法是將現(xiàn)有表的字段修改為自增字段:DB2=> alter table organunode alter column ID set GENERATED ALWAYS AS標(biāo)識(從1開始,遞增1,無緩存)
DB2數(shù)據(jù)庫表中有個字段允許為空,怎么改為不允許為空?
如果要添加非空字段,可以先將其放入默認(rèn)值。例如,如果要在Scott的EMP中添加一個非空的列“t”,可以編寫alter table EMP add t number(8)default(0)not nullnot null and default cannot change position
alter table name add column field char(1)check(field in(“t”,“f”)
對列模式名進(jìn)行注釋。表名。字段上的注釋是“t和f”