🐘 PostgreSQL - DELETE / TRUNCATE
Updated at 2015-09-23 23:55
All statements works in PostgreSQL 9.1+. For more PostgreSQL notes, check out PostgreSQL Guide
Deleting matching rows.
DELETE FROM task WHERE status = 'DONE';
DELETE FROM film WHERE producer_id IN ( SELECT id FROM producer WHERE name = 'foo' );
TRUNCATE empties a table and the related tables. Really useful for development and testing.
TRUNCATE some_table CASCADE;