简体   繁体   English

无法在MySQL中更改或删除表

[英]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: 我需要对MySQL INNODB表进行一些架构更改(从INT到BIGINT的主键列大小)...似乎我必须删除主键...但是如果我尝试:

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

I get: 我明白了:

ERROR 1025: Error on rename of '.\\myschema#sql-1344_36' to '.\\myschema\\mytable' (errno: 150) 错误1025:将'。\\ myschema#sql-1344_36'重命名为'。\\ myschema \\ mytable'时出错(错误号: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 错误1217:无法删除或更新父行:外键约束失败

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 我返回零行,表明还有一些其他依赖关系未通过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? 我怎样才能确定它以及我可以使用哪种纠正措施?

SET FOREIGN_KEY_CHECKS=0

DROP你的表并再次设置为1

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM