'Postgresql delete without DELETE CASCADE

I have some rows to delete from a table:

DELETE FROM my_table WHERE id=1

However the row with id=1 is referenced in another_table as a foreign key.

In an ideal world, it would cascade and also delete the related entry in another_table. However the foreign key wasn't references as cascade delete and has null=False. So deleting the element with id=1 in my_table cannot be achieved with the query from above because it would cause an integrity error in another_table.

Is there something like:

DELETE CASCADE FROM my_table WHERE id=1

Which deletes related foreign keys?

Alternatively is there another way to do this?

Thanks.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source