Srinivasan
Srinivasan

Reputation: 12050

MYSQL - Cannot able to drop a column

I am using MYSQL 5.1. When i try to drop a column in a table, it throws the following error. MATERIAL_OUTWARD_ID is a foreign key.

Query:

alter table `tispa`.`customer_invoice` drop `MATERIAL_OUTWARD_ID`

Error:

Error on rename of '.\tispa\#sql-78_8' to '.\tispa\customer_invoice' (errno: 150)

Upvotes: 1

Views: 1859

Answers (2)

Srinivasan
Srinivasan

Reputation: 12050

I have fixed it.

First drop the foreign key like

alter table `tispa`.`customer_invoice` drop foreign key  `FK_material_out_id` ;

Then drop the column like

alter table `tispa`.`customer_invoice` drop `MATERIAL_OUTWARD_ID`;

It will work.

Upvotes: 1

ghostdog74
ghostdog74

Reputation: 343067

try dropping the foreign key?

alter table 
...
DROP FOREIGN KEY MATERIAL_OUTWARD_ID

Upvotes: 1

Related Questions