Redian新闻
>
No Need for trigger Re: oracle trigger question
avatar
No Need for trigger Re: oracle trigger question# Database - 数据库
B*n
1
In this case, you dont even need a trigger. It is
automatically
handled by database referential constraints. Basically you
need
to specify the DELETE CASCADE constraint when creating table
A
that has a forien key referencing table B.
here is an example:
suppose you have the table B which has deptno as a primary
key:
SQL> select * from B;
DEPTNO DNAME LOC
avatar
h*r
2
Thanks a lot,
my worry is if I do:
SQL>delete B;
Will it also remove the related items in the table A
automatically? That means we will not delete records
from table B one by one, but delete all at the same
time, will the referential work?

【在 B*****n 的大作中提到】
: In this case, you dont even need a trigger. It is
: automatically
: handled by database referential constraints. Basically you
: need
: to specify the DELETE CASCADE constraint when creating table
: A
: that has a forien key referencing table B.
: here is an example:
: suppose you have the table B which has deptno as a primary
: key:

avatar
B*n
3
at least in Oracle, you will not be able to drop table B if
there are still rows in A that have foreign keys referencing
B. you will get an error if you try to drop B.

【在 h****r 的大作中提到】
: Thanks a lot,
: my worry is if I do:
: SQL>delete B;
: Will it also remove the related items in the table A
: automatically? That means we will not delete records
: from table B one by one, but delete all at the same
: time, will the referential work?

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。