I have a table in my DB, in which every row has a parent id which is the id of another row in the table (the table represents a tree-like structure). I would like to empty the table. But when I perform
DELETE FROM table_name WHERE true;
I get an error (foreign key constraint). How do I empty the table anyway?
Clarification: I want to delete the whole table’s contents, not the tables themselves.
When you create your foreign key relationships, you need to specify
on delete cascade.EDIT: There’s a pretty good reference right here: http://en.wikipedia.org/wiki/Foreign_key