检查 Oracle 中两个表的约束

Check constraints on two tables in Oracle

我有两个具有一对一关系的表(并且关系仅从一侧是强制性的)。如下:

create table PRS (
  id number(18) not null,
  common_code varchar2(10),
  constraint pk_prs primary key (id));

create table RLP {
  id number(18),
  spec_code varchar2(20),
  constraint pk_rlp primary key (id),
  constraint fk_rlp_prs foreign key (id) references prs(id) on delete cascade);

所以问题是在 RLP 中插入记录时,至少 common_codespec_code 之一必须有值。

是否可以使用约束来强制执行此约束,或者唯一的解决方案是使用触发器?

似乎没有办法在两个表上创建约束,唯一的解决方案是创建一个触发器以在需要的情况下抛出异常。