sql语句添加删除外键及其约束

--删除外键

ALTER TABLE t_base_role_module

DROP CONSTRAINT fk_t_base_role_module_t_base_defined_url;

--增加外键

ALTER TABLE t_base_role_module

ADD CONSTRAINT fk_t_base_role_module_t_base_defined_url

FOREIGN KEY (module_id)

REFERENCES t_base_defined_url (module_id)

ON DELETE CASCADE;

--不检查约束
alter table 表 nocheck constraint fk_name

--检查约束
alter table 表 check constraint fk_name

原文地址:https://www.cnblogs.com/haimishasha/p/6653738.html