我在 IBMi/System-i/iSeries/AS400 上有一个表,它没有外键、主键或任何类型的约束。我正在尝试使用 SQL 添加主键:
ALTER TABLE MYLIB.TBLGB ADD CONSTRAINT MYLIB.R_MYLIB_PK_GB PRIMARY KEY (GBAPP, GBTSK, GBSET, GBSTP)
结果是:
Error: [SQL0538] The FOREIGN key in constraint R_MYLIB_PK_GB in MYLIB not same as the parent key. Cause . . . . . : The FOREIGN key in constraint R_MYLIB_PK_GB in MYLIB is not the same as the parent key of table *N in *N. The FOREIGN key must have the same number of columns as the parent key and the data type and attributes of the FOREIGN key must be identical to the data type and attributes of the corresponding column of the parent key. Recovery . . . : Correct the statement so that the description of the FOREIGN key conforms to that of the parent key of the specified table.
我对此完全感到困惑,因为绝对没有外键链接到该表。事实上,我已经从这个库中的所有表中删除了所有约束。我可以查看什么来确定是什么阻止了这个?
另一个有趣的细节是,这在其他基本相同的库上运行良好......