如题,怎样先判断外键是否存在,然后在删除,像
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/69209691161257.html
Copyright © 2019- 222spj.com 版权所有
违法及侵权请联系:TEL:199 18 7713 E-MAIL:2724546146@qq.com
本站由北京市万商天勤律师事务所王兴未律师提供法律服务