Rename column in DB2
10,496
Drop the constraint:
ALTER TABLE TPR.PRODUCT_FEATURE
DROP CONSTRAINT PRODUCT_FEATURE_X01
Then alter your table:
ALTER TABLE TPR.PRODUCT_FEATURE RENAME COLUMN PRODUCT_ID TO SERVICE_ID
Then add new constraint:
ALTER TABLE TPR.PRODUCT_FEATURE
ADD CONSTRAINT PRODUCT_FEATURE_X01
PRIMARY KEY (insert,columns,here)
Author by
RUC
Updated on June 11, 2022Comments
-
RUC almost 2 years
I am trying to rename a column in one table where data already exists. But below is the error it is throwing.Please advice.
Syntax I tried
ALTER TABLE TPR.PRODUCT_FEATURE RENAME COLUMN PRODUCT_ID TO SERVICE_ID
Error:
[Error] Script lines: 23-23 ------------------------ DROP, ALTER, TRANSFER OWNERSHIP, REVOKE, or CREATE OR REPLACE on object type "COLUMN" cannot be processed because there is an object "PRODUCT_FEATURE_X01", of type "PRIMARY KEY", which depends on it.. SQLCODE=-478, SQLSTATE=42893, DRIVER=3.67.28
Looks me to, I need to drop and recreate is the only option. Please advice.