this answer
它说要指定空值,但它似乎对我没有影响。这就是我所拥有的:
CREATE TABLE stops
(
stop_id text PRIMARY KEY,
--stop_code text NULL,
stop_name text NOT NULL,
--stop_desc text NULL,
stop_lat double precision NOT NULL,
stop_lon double precision NOT NULL,
zone_id integer NULL,
stop_url text NULL,
location_type boolean NULL,
parent_station text NULL
);
\copy stops from './stops.txt' with csv header NULL AS ''
我也试过用
\N
这样的性格:
\copy stops from './stops.txt' with csv header NULL AS '\N'
但似乎没有效果。
我还尝试了一种解决方案
here
\copy agency from './agency.txt' WITH (FORMAT csv header, FORCE_NULL(zone_id))
csv_header
部分。
版本是9.6。
stop_id,stop_name,stop_lat,stop_lon,zone_id,stop_url,location_type,parent_station
"de:07334:1714:1:1","Wörth Alte Bahnmeisterei","49.048742345982","8.26622538039577","","","","Parent1714"
"de:07334:1714:1:2","Wörth Alte Bahnmeisterei","49.0484420719247","8.26673742010779","","","","Parent1714"
"de:07334:1721:1:1","Maximiliansau EisenbahnstraÃe","49.0373071007148","8.29789997731824","","","","Parent1721"
"de:07334:1721:2:2","Maximiliansau EisenbahnstraÃe","49.0371363175998","8.29896897250649","","","","Parent1721"