Reputation: 52840
How can I solve FK contraint? With trigger or something else?
#IF "DELETE FROM human where name='a';", error due to the FK contraist.
# If the error, I want in the order:
# FIRSTLY. DELETE FROM address where name='a';
# SECONDLY. DELETE FROM human where name='a';
DROP TABLE human;
DROP TABLE address;
CREATE TABLE human(
name varchar(300) PRIMARY KEY not null
);
CREATE TABLE address(
name varchar(300)
references human.name
);
Upvotes: 0
Views: 172
Reputation: 62593
Chapter 5.3.5. Foreign Keys of the fine manual would be very helful.
Upvotes: 0
Reputation: 143099
CREATE TABLE address (
name varchar(300) REFERENCES human (name) ON DELETE CASCADE
);
Is that what you want?
Upvotes: 3