Db2 – Cannot drop primary key or add primary key

db2db2-midrangeiseries

This db2 query:

alter table mylib.mytable add primary key(field1, field2, field3)

returns

[SQL0624] Table MYTABLE in MYLIB already has a primary key'.

However

alter table mylib.mytable drop primary key

returns:

[SQL0539] Table MYTABLEin MYLIB does not have a primary or unique key'.

How can I remove the existing primary key and create the new one?

The file was created in green screen, not by executing a SQL CREATE TABLE. The database version is V7R2.

Best Answer

You can find all FKEY/PKEY/CHECK Constraints in QSYS2.TABLE_CONSTRAINTS to see and/or remove any keys built on the table.