1

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.

このテーブルにリンクされた外部キーは絶対にないので、私はこれに完全に困惑しています。実際、このライブラリのすべてのテーブルからすべての制約を削除しました。これを妨げているものを特定するには、何を確認できますか?

追加の興味深い詳細の1つは、これが他の本質的に同一のライブラリでうまく機能したことです...

4

3 に答える 3

0

制約はスキーマによって修飾されます。したがって、mylib というスキーマも持っていない限り、修飾を削除してください。

テーブルについて不平を言う理由は、おそらく、スキーマ systables でテーブルを見つけようとするためですが、それは純粋な推測です。

于 2012-04-05T20:01:54.757 に答える