delete in postgresql code example

Example 1: how to remove tables from postgresql

DROP TABLE IF EXISTS tablename;

Example 2: delete entries in postgresql

DELETE FROM table WHERE condition;

Example 3: postegresql delete

DELETE FROM films
  WHERE producer_id IN (SELECT id FROM producers WHERE name = 'foo');

Example 4: delete entries in postgresql

DELETE FROM table
USING another_table
WHERE table.id = another_table.id;

Example 5: delete from select postgresql

DELETE FROM mytable 
WHERE ctid IN (
    SELECT ctid
    FROM mytable 
    GROUP BY s.serialId, s.valuetimestamp
    ORDER BY s.serialId
    LIMIT 10
)

Tags:

Misc Example