让我们考虑以下两个简化的表格:
CREATE TABLE payments
(
id bigserial NOT NULL PRIMARY KEY,
method int,
method_name name,
total numeric,
payment_date timestamp without time zone,
is_seccessful boolean,
data jsonb
);
CREATE TABLE subscription_payments
(
subscription_id int,
parent_id bigint,
CONSTRAINT pk_subscription_id FOREIGN KEY (subscription_id)
REFERENCES subscriptions (id)
ON DELETE RESTRICT
)
INHERITS (payments);
现在,如何创建subscription_payments.parent_id
to的外键引用payments.id
,使其不引用其他继承表?
换句话说,我该如何参考subscription_payments.id
?