I am still relatively new to psql and I was just finishing an assignment when I decided to try something which was to drop a table which other tables depend on due to a foreign key relationship. My expectation was that any table that had a foreign key reference to the table I am dropping will have (at least) all their rows deleted and the table dropped as well.
This was not the case. The tables are still there and even though I specified
CASCADE, nothing happened to the rows of those tables.
TRUNCATE ... CASCADE on the referenced table does in fact remove the rows in the other tables
EDIT: Ok, I understand it does this because this is the way it has been specified by the documentation, but my question now is, when is this ever expected behaviour?
- DROPing a domian with CASCADE removes every column in any table that uses that domain.
- DROPing a table with a view attached to it will delete the view.
Why does it make sense that dropping a table which is referenced by other tables does not delete the tables that reference this one as well? Convienience?