User Tools

Site Tools


snippets:postgresql

**This is an old revision of the document!**

move rows to another table

CREATE TABLE history_0 AS
WITH moved_rows AS (
    DELETE FROM current
    WHERE current.date < (now() - '6 Months'::interval)
    RETURNING * -- or specify columns
)
SELECT * FROM moved_rows;
snippets/postgresql.1476094717.txt.gz · Last modified: (external edit)