siki
siki

Reputation: 9477

PostgreSQL delete from parent table only

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.

Upvotes: 5

Views: 4202

Answers (1)

Tomasz Siorek
Tomasz Siorek

Reputation: 711

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

Upvotes: 11

Related Questions