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

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

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-11-30 23:59:58
Original
3074 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:
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
Latest Issues
MySQL stops process
From 1970-01-01 08:00:00
0
0
0
Error when installing mysql on linux
From 1970-01-01 08:00:00
0
0
0
phpstudy cannot start mysql?
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template