简体   繁体   English

删除时删除级联MySQL

[英]Remove On Delete Cascade MySQL

I've created 2 tables one named (Config) and the other one (Records): 我创建了2个表,一个表名为(Config),另一个表(Records):

 CREATE TABLE Config(
   configID VARCHAR(100)  NOT NULL,
   featureID VARCHAR(100) NOT NULL,
   bpID VARCHAR(100),
PRIMARY KEY (configID, featureID)
);


CREATE TABLE Records(
   tID VARCHAR(100)  NOT NULL,
   configID VARCHAR(500) NOT NULL,
PRIMARY KEY (tID),
FOREIGN KEY (configID)  REFERENCES Config (configID) ON DELETE CASCADE

);

I want to remove the constraint "ON DELETE CASCADE" from the second table. 我想从第二个表中删除约束“ ON DELETE CASCADE”。 I tried to delete the FK first and then delete the table to re-create it but I'm getting this error "Error of rename (Error: 152)". 我尝试先删除FK,然后删除表以重新创建它,但出现此错误“重命名错误(错误:152)”。

Any suggestions? 有什么建议么? Thank you, 谢谢,

Two suggestions: 两个建议:

  1. Try to alter table and switch from cascade back to default/no action 尝试更改表并从级联切换回默认/无操作
  2. Drop the foreign key constraint and recreate table 删除外键约束并重新创建表

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

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