Delete rows with foreign key in PostgreSQL
To automate this, you could define the foreign key constraint with ON DELETE CASCADE. I quote the the manual for foreign key constraints: CASCADE specifies that when a referenced row is deleted, row(s) referencing it should be automatically deleted as well. Look up the current FK definition like this: SELECT pg_get_constraintdef(oid) AS constraint_def FROM pg_constraint … Read more