Zenilogix
Zenilogix

Reputation: 1393

Unable to alter or drop a table in MySQL

I need to make some schema changes to a MySQL INNODB table (up-size the primary key column from INT to BIGINT)... seems I have to drop the primary key... but if I attempt to:

ALTER TABLE `myschema`.`mytable` DROP PRIMARY KEY

I get:

ERROR 1025: Error on rename of '.\myschema#sql-1344_36' to '.\myschema\mytable' (errno: 150)

I can afford to drop the whole table and recreate it (small table with just a few data rows); however if I attempt to:

drop table `myschema`.`mytable`

I get:

ERROR 1217: Cannot delete or update a parent row: a foreign key constraint fails

If I do:

use INFORMATION_SCHEMA;
select * from KEY_COLUMN_USAGE WHERE REFERENCED_TABLE_NAME = 'mytable';

I get zero rows returned, suggesting that there is some other dependency not revealed through KEY_COLUMN_USAGE

I'd rather not drop the whole schema (rather not have to reload all the data)...

What could be preventing me from making my desired schema change? How could I identify it and what sort of corrective measures would be available to me?

Upvotes: 0

Views: 491

Answers (1)

Mihai
Mihai

Reputation: 26784

SET FOREIGN_KEY_CHECKS=0

DROP your table and set it again to 1

Upvotes: 2

Related Questions