如何改变约束

How to Alter Constraint(如何改变约束)
本文介绍了如何改变约束的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

SQL 如何改变约束

以下是我的约束条件之一

Below is 1 of my constraint

CONSTRAINT ACTIVEPROG_FKEY1 FOREIGN KEY(ActiveProgCode) REFERENCES PROGRAM(ActiveProgCode),

我想加入

ON DELETE CASCADE

到上面的约束.

如何更改现有约束 ACTIVEPROG_FKEY1 并添加

How do i alter that existing constraint ACTIVEPROG_FKEY1 and add

ON DELETE CASCADE

约束ACTIVEPROG_FKEY1

to constraint ACTIVEPROG_FKEY1

考虑 ACTIVEPROG_FKEY1 在表 ACTIVEPROG

Consider ACTIVEPROG_FKEY1 is at Table ACTIVEPROG

推荐答案

你永远不能改变约束,但你可以删除它们然后重新创建.

You can not alter constraints ever but you can drop them and then recreate.

看看这个

ALTER TABLE your_table DROP CONSTRAINT ACTIVEPROG_FKEY1;

然后像这样用ON DELETE CASCADE重新创建它

and then recreate it with ON DELETE CASCADE like this

ALTER TABLE your_table
add CONSTRAINT ACTIVEPROG_FKEY1 FOREIGN KEY(ActiveProgCode) REFERENCES PROGRAM(ActiveProgCode)
    ON DELETE CASCADE;

希望对您有所帮助

这篇关于如何改变约束的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Execute complex raw SQL query in EF6(在EF6中执行复杂的原始SQL查询)
Hibernate reactive No Vert.x context active in aws rds(AWS RDS中的休眠反应性非Vert.x上下文处于活动状态)
Bulk insert with mysql2 and NodeJs throws 500(使用mysql2和NodeJS的大容量插入抛出500)
Flask + PyMySQL giving error no attribute #39;settimeout#39;(FlASK+PyMySQL给出错误,没有属性#39;setTimeout#39;)
auto_increment column for a group of rows?(一组行的AUTO_INCREMENT列?)
Sort by ID DESC(按ID代码排序)