Postgres COPY FROM csv file- No such file or directory

后端 未结 5 815
失恋的感觉
失恋的感觉 2021-02-04 01:34

I\'m trying to import a (rather large) .txt file into a table geonames in PostgreSQL 9.1. I\'m in the /~ directory of my server, with a file named US.txt placed in that director

5条回答
  •  一整个雨季
    2021-02-04 01:34

    A couple of misconceptions:

    1.

    I'm in the /~ directory of my server

    There is no directory /~. It's either / (root directory) or ~ (home directory of current user). It's also irrelevant to the problem.

    2.

    I set the search_path variable to geochat, the name of the database I'm working in

    The search_path has nothing to do with the name of the database. It's for schemas inside the current database. You probably need to reset this.

    3.
    You are required to use the absolute path for your file. As documented in the manual here:

    filename

    The absolute path name of the input or output file.

    4.
    DELIMITER: just noise.

    The default is a tab character in text format

    5.
    NULL: It's rather uncommon to use the actual string 'NULL' for a NULL value. Are you sure?

    The default is \N (backslash-N) in text format, and an unquoted empty string in CSV format.

    My guess (after resetting search_path - or you schema-qualify the table name):

    COPY geonames FROM '/path/to/file/US.txt';
    

提交回复
热议问题