[Expanding on dvv’s answer]
You can move to an existing table as follows. For unmatched schema, you should specify columns.
WITH moved_rows AS (
DELETE FROM <original_table> a
USING <other_table> b
WHERE <condition>
RETURNING a.* -- or specify columns
)
INSERT INTO <existing_table> --specify columns if necessary
SELECT [DISTINCT] * FROM moved_rows;
But you want to move the data into a new table (not an existing one), the outer syntax is different:
CREATE TABLE <new_table> AS
WITH moved_rows AS (
DELETE FROM <original_table> a
USING <other_table> b
WHERE <condition>
RETURNING a.* -- or specify columns
)
SELECT [DISTINCT] * FROM moved_rows;
Note: "USING <other_table> b" will join a with b so that you can delete rows from a based on the join result. If you don’t have any other_table to join, you can just omit this. See here for more info.