MySQL eliminar la restricción de clave extranjera
ALTER TABLE jobs DROP FOREIGN KEY constraint_name
Hiren Reshamwala
ALTER TABLE jobs DROP FOREIGN KEY constraint_name
SET foreign_key_checks = 0;
CREATE TABLE parent (
id INT NOT NULL,
PRIMARY KEY (id)
) ENGINE=INNODB;
CREATE TABLE child (
id INT,
parent_id INT,
INDEX par_ind (parent_id),
FOREIGN KEY (parent_id)
REFERENCES parent(id)
ON DELETE CASCADE
) ENGINE=INNODB;
ALTER TABLE table_name DROP FOREIGN KEY constraint_name
SET FOREIGN_KEY_CHECKS = 0;
drop table if exists customers;
drop table if exists orders;
drop table if exists order_details;
SET FOREIGN_KEY_CHECKS = 1;
ALTER TABLE table_name
DROP FOREIGN KEY constraint_name;
Code language: SQL (Structured Query Language) (sql)