我试过了:
CREATE TABLE rowid_type
(
col1 ROWID NOT NULL GENERATED ALWAYS,
col2 int
);
错误:
错误:DB2 SQL错误:SQLCODE = -104,SQLSTATE = 42601,SQLERRMC = GENERATED ALWAYS; col1 ROWID NOT NULL;,DRIVER = 4.14.111
SQLState:42601
ErrorCode:-104
它显示:
CREATE TABLE EMPLOYEE
(EMP_ROWID ROWID NOT NULL GENERATED ALWAYS,
EMPNO SMALLINT,
NAME CHAR(30),
SALARY DECIMAL(7,2),
WORKDEPT SMALLINT);
答案 0 :(得分:1)
[我的回答适用于DB2 LUW,问题已经更新,现在指向DB2 for z / OS]
尝试这样的事情:
CREATE TABLE rowid_type
(
col1 int NOT NULL GENERATED ALWAYS AS IDENTITY,
col2 int
);
还有更多选项可用,例如设置开始值和停止值。有关详细信息,请参阅DB2 docs on identity columns。