Question

I have a curious issue with a simple drop column query in DB2. I have done some research and the syntax seems to be apparently correct but still I have en error. Here is the query:

alter table ed2.batch_job_instance drop column prova;

The table exists, the column also (which is a simple nullable varchar) but still I have this error:

ILLEGAL USE OF KEYWORD COLUMN. TOKEN QUERY MATERIALIZED PRIMARY FOREIGN CONSTRAINT RESTRICT UNIQUE WAS EXPECTED SQL Code: -199, SQL State: 42601

What am I doing wrong? Thanks in advance.

Était-ce utile?

La solution

Please check if the column PROVE is not included in some constraint. UNIQUE maybe ? In that case you will have to delete (drop) the constraint first.

UPDATE: according to docs for V10: http://publib.boulder.ibm.com/infocenter/dzichelp/v2r2/index.jsp?topic=%2Fcom.ibm.db2z10.doc.sqlref%2Fsrc%2Ftpc%2Fdb2z_sql_altertable.htm there is no such thing as DROP COLUMN.

Also othere source: http://publib.boulder.ibm.com/infocenter/dzichelp/v2r2/index.jsp?topic=%2Fcom.ibm.db2z10.doc.admin%2Fsrc%2Ftpc%2Fdb2z_altertables.htm don't even mention that possibility (but add column is indicated).

EDIT: You would have to use something like this:

EXPORT TO data.ixf OF IXF SELECT COL1, COL2 FROM TABLE1;
DROP TABLE TABLE1;
CREATE TABLE TABLE1 (COL1 ..., COL2 ...);
IMPORT FROM data.ixf OF IXF INSERT INTO TABLE1;

reference: http://bytes.com/topic/db2/answers/810167-can-i-drop-cloumn-table-db2-z-os

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top