如何改变约束

2021-12-06 00:00:00 sql oracle

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;

希望对您有所帮助

相关文章