Home  >  Article  >  Database  >  How does mysql determine whether a foreign key exists before deleting it?

How does mysql determine whether a foreign key exists before deleting it?

WBOY
WBOYOriginal
2016-11-30 23:59:582984browse

mysql

As mentioned, how to first determine whether the foreign key exists and then delete it, like
if EXISTS((SELECT COUNT(*) FROM information_schema.KEY_COLUMN_USAGE where constraint_name='fk_emp_dept_id') > 0)
alter table org_employee drop foreign key fk_emp_dept_id;
Also,
if EXISTS((SELECT COUNT(*) FROM information_schema.KEY_COLUMN_USAGE where constraint_name='fk_emp_dept_id') > 0)
BEGIN
alter table org_employee drop foreign key fk_emp_dept_id;
END
will report an error, please give me an answer

Reply content:

https://zhidao.baidu.com/question/692089969116125764.html

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn