0
如果存在另一個包含它的外鍵的記錄,postgres是否有辦法阻止記錄被刪除?Postgres:防止刪除如果存在關聯
如果存在另一個包含它的外鍵的記錄,postgres是否有辦法阻止記錄被刪除?Postgres:防止刪除如果存在關聯
您可以在這個例子中,第二行SQL
CREATE TABLE order_items (
product_no integer REFERENCES products ON DELETE RESTRICT,
order_id integer REFERENCES orders ON DELETE CASCADE,
quantity integer,
PRIMARY KEY (product_no, order_id)
);
真棒,這就是我要尋找「限制」字限制刪除。謝謝! – stellard
@stellard:你可以忽略'RESTRICT',因爲這是默認值。 –