psql invalid command \N while restore sql

前端 未结 14 876
后悔当初
后悔当初 2020-12-04 15:54

I\'m trying to restore my dump file, but it caused an error:

psql:psit.sql:27485: invalid command \\N

Is there a solution? I searched, but

14条回答
  •  佛祖请我去吃肉
    2020-12-04 16:55

    Same thing was happened to me today. I handled issue by dumping with --inserts command.

    What I do is:

    1) pg_dump with inserts:

    pg_dump dbname --username=usernamehere --password --no-owner --no-privileges --data-only --inserts -t 'schema."Table"' > filename.sql
    

    2) psql (restore your dumped file)

    psql "dbname=dbnamehere options=--search_path=schemaname" --host hostnamehere --username=usernamehere -f filename.sql >& outputfile.txt
    

    Note-1 ) Make sure that adding outputfile will increase speed of import.

    Note-2 ) Do not forget to create table with exact same name and columns before importing with psql.

提交回复
热议问题