简体   繁体   中英

Remove On Delete Cascade MySQL

I've created 2 tables one named (Config) and the other one (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. 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)".

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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