Home > Database > Mysql Tutorial > body text

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

WBOY
Release: 2016-11-30 23:59:58
Original
3009 people have browsed it

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

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template