Skip to content

Instantly share code, notes, and snippets.

@rollxx
Last active September 20, 2016 08:08
Show Gist options
  • Save rollxx/edcab2a060af1040bc1af30f78de0cfe to your computer and use it in GitHub Desktop.
Save rollxx/edcab2a060af1040bc1af30f78de0cfe to your computer and use it in GitHub Desktop.
import allocation with extra temporal table to filter out the unneeded fields
CREATE TEMPORARY TABLE t (
location VARCHAR(255),
car_group_id SERIAL8,
start_timestamp TIMESTAMP WITH TIME ZONE,
end_timestamp TIMESTAMP WITH TIME ZONE,
ignore1 TEXT,
ignore2 TEXT,
ignore3 TEXT
);
COPY t (location, car_group_id, start_timestamp, end_timestamp, ignore1, ignore2, ignore3)
FROM E'D:\\zz.csv' DELIMITER ';' CSV HEADER;
INSERT INTO allocations (fromtimestamp, totimestamp, cargroup_id, repairsite_id, version)
SELECT
start_timestamp,
end_timestamp,
car_group_id,
1,
0
FROM t;
DROP TABLE t;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment