psql invalid command \N while restore sql

前端 未结 14 884
后悔当初
后悔当初 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:50

    In my recent experience, it's possible to get this error when the real problem has nothing to do with escape characters or newlines. In my case, I had created a dump from database A with
    pg_dump -a -t table_name > dump.sql
    and was trying to restore it to database B with
    psql < dump.sql (after updating the proper env vars, of course)
    What I finally figured out was that the dump, though it was data-only (the -a option, so that the table structure isn't explicitly part of the dump), was schema-specific. That meant that without manually modifying the dump, I couldn't use a dump generated from schema1.table_name to populate schema2.table_name. Manually modifying the dump was easy, the schema is specified in the first 15 lines or so.

提交回复
热议问题