sql >> Database teknologi >  >> RDS >> PostgreSQL

Postgresql COPY CSV FEJL:ekstra data efter sidste forventede kolonne

Virker som en charme, her ...

DROP TABLE zipcodes CASCADE;
CREATE TABLE zipcodes
        ( id serial NOT NULL PRIMARY KEY
        , zzip varchar NOT NULL UNIQUE
        , ztype varchar
        , primary_city varchar
        , acceptable_cities varchar
        , unacceptable_cities varchar
        , state varchar
        , county varchar
        , ztimezone varchar
        , area_codes varchar
        , latitude varchar
        , longitude varchar
        , world_region varchar
        , country varchar
        , decommissioned varchar
        , estimated_population varchar
        , notes varchar
        ); 

COPY zipcodes (zzip,ztype,primary_city
     , acceptable_cities,unacceptable_cities
     , state,county,ztimezone,area_codes 
     , latitude,longitude,world_region,country
     , decommissioned,estimated_population,notes )
FROM '/tmp/zip_code_database.csv'
        WITH CSV HEADER delimiter ','
        ;

Resultat:

DROP TABLE
CREATE TABLE
COPY 42522

(måske OP har CR/CRLF problemer?)




  1. Problem med JPA, EclipseLink og store og små bogstaver i mysql

  2. Kryptering i hvile og/eller AES_ENCRYPT

  3. Kodning i RORacle

  4. kan jeg konfigurere cron job til localhost