如题,怎样先判断外键是否存在,然后在删除,像
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
;
还有,
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
都会报错,求大神解答
https://zhidao.baidu.com/question/692089969116125764.html
声明:本网页内容旨在传播知识,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。TEL:177 7030 7066 E-MAIL:11247931@qq.com