IT分销/经销数据库

如何把一个列修改成自增长

有一个表,比如有一个已存在的列row_id,原先是int类型但不是自增长,现在想把它修改成自增长,请问如何修改,操作系统是as400 的 .
参与6

3同行回答

Xiao QingXiao Qing系统工程师浪潮商用机器有限公司
在DB2/400中,可以用下面的语句自动生成数字序列。 CREATE TABLE TWTLIB/IDTEST (empid int not null generated always as identity (start with 1 increment by 1 no cycle no cache), empno char(30) ) 仅供参考。显示全部

在DB2/400中,可以用下面的语句自动生成数字序列。
CREATE TABLE TWTLIB/IDTEST

(empid int not null

generated always as identity

(start with 1

increment by 1

no cycle

no cache),

empno char(30)

)

仅供参考。

收起
系统集成 · 2021-02-24
浏览407
lucas1643lucas1643软件工程师PCCW
Alter table alter column set generated always as identity (start with 1,increment by 1)显示全部
Alter table alter column set generated always as identity (start with 1,increment by 1)收起电信设备制造商 · 2010-10-26
浏览511
alleachinealleachine技术经理胜科金仕达数据系统(中国)有限公司
一、导出该表的数据;二、删除原表,重新建,新建表脚本修改row_id字段属性增加‘GENERATED BY DEFAULT as IDENTITY’;三、导入数据。DB21085I  Instance "db2inst1" uses "32" bits and DB2 code release "SQL08027" with level identifier "03080106".Informationa...显示全部
一、导出该表的数据;
二、删除原表,重新建,新建表脚本修改row_id字段属性增加‘GENERATED BY DEFAULT as IDENTITY’;
三、导入数据。
DB21085I  Instance "db2inst1" uses "32" bits and DB2 code release "SQL08027"
with level identifier "03080106".
Informational tokens are "DB2 v8.1.2.128", "s061108", "MI00176", and FixPak
"14".
Product is installed at "/opt/IBM/db2/V8.1".收起
证券 · 2010-10-25
浏览545
X社区推广