psql invalid command \N while restore sql

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

    I followed all these example's and they all failed with the error we are talking about:

    Copy a table from one database to another in Postgres

    What worked was the syntax with -C, see here:

    pg_dump -C -t tableName "postgres://$User:$Password@$Host:$Port/$DBName" | psql "postgres://$User:$Password@$Host:$Port/$DBName"
    

    Also if there are differing Schema's between the two, I find altering one dB's schema to match the others is necessary for Table copies to work, eg:

    DROP SCHEMA public;
    ALTER SCHEMA originalDBSchema RENAME TO public;
    

提交回复
热议问题