DB2自动增长主键的方法
DB2可以使用generated always as identity 将某一个字段指定为自增长的字段,比如:create table user (name varchar(30),
id integer generated always as identity (start with 1 increment by 1))
这表示id自动是一个自增长的字段,它从1开始增加每次增加1。也可以通过generated 将字段的值通过其他字段的计算的来,比如;
create table user(name varchar(30),
n1 integer,
n2 integer ,
id integer generated always as (n1+n2))
页:
[1]