PostgreSQL delete from parent table only

postgresql, postgresql-9.1, sql

Solution

You can specify that only parent table matters, simply by using keyword 'ONLY':

DELETE FROM ONLY parent_table_name;

See: http://www.postgresql.org/docs/current/static/sql-delete.html

Problem

I have a table structure with partitioned tables, where a few child tables inherit from a common parent. How so I `DELETE` only from the parent table? Long story short, I ended up with some data in the parent table, and this should've never happened but now I have to clean up the mess.

Original source