9.1.2.1 Copying Data

CREATE TABLE temp_location (LIKE location);

INSERT INTO temp_location SELECT * FROM location q
WHERE user_id=29 AND time >= '2015-12-14' AND
time <= '2015-12-14T23:59:59'

UPDATE temp_location SET user_id=3, id=NEXTVAL('location_seq'::regclass);

INSERT INTO location SELECT * FROM temp_location;