Remove On Delete Cascade MySQL

1.3k Views Asked by At

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,

1

There are 1 best solutions below

0
On

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