How to AUTO_INCREMENT in db2?

前端 未结 4 551
轻奢々
轻奢々 2020-12-05 17:17

I thought this would be simple, but I can\'t seem to use AUTO_INCREMENT in my db2 database. I did some searching and people seem to be using \"Generated by Default\", but t

4条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-05 17:48

    hi If you are still not able to make column as AUTO_INCREMENT while creating table. As a work around first create table that is:

    create table student( sid integer NOT NULL sname varchar(30), PRIMARY KEY (sid) );

    and then explicitly try to alter column bu using the following

    alter table student alter column sid set GENERATED BY DEFAULT AS IDENTITY

    Or

    alter table student alter column sid set GENERATED BY DEFAULT AS IDENTITY (start with 100)

提交回复
热议问题