I've been looking at other posts. It seems many people have had this problem, but I'm somewhat new to Postgres and tried other solutions with no luck.
I have ny_stations table:
CREATE TABLE ny_stations ( id integer primary key, name text, latitude numeric, longitude numeric, nyct2010_gid integer, boroname text, ntacode text, ntaname text );
I am trying to insert values from another table, ny_raw_trips:
INSERT into ny_stations (id, name, latitude, longitude) SELECT DISTINCT start_station_id, start_station_name, start_station_latitude, start_station_longitude FROM ny_raw_trips WHERE start_station_id NOT IN (SELECT id FROM ny_stations);
Getting the error:
ERROR: duplicate key value violates unique constraint "ny_stations_pkey"
DETAIL: Key (id)=(151) already exists.
What am I doing wrong? Also,
SELECT pg_get_serial_sequence('ny_stations', 'id');
...returns nothing. Please let me know if any other info is required.