PostgreSQL
 SQL >> Datenbank >  >> RDS >> PostgreSQL

Warum pg_restore -d/--dbname nicht zusammen mit -f/--file akzeptiert

Das Flag -f ist der Ausgabe-Dateiname, nicht die Eingabedatei. Die Eingabedatei kommt ganz ohne Optionsschalter aus.

c:\>pg_restore --help
pg_restore restores a PostgreSQL database from an archive created by pg_dump.

Usage:
  pg_restore [OPTION]... [FILE]

General options:
  -d, --dbname=NAME        connect to database name
  -f, --file=FILENAME      output file name
  -F, --format=c|d|t       backup file format (should be automatic)
  -l, --list               print summarized TOC of the archive
  -v, --verbose            verbose mode
  -V, --version            output version information, then exit
  -?, --help               show this help, then exit

Richtig lautet der Aufruf also:

pg_restore.exe -h localhost -U postgres -d Mydata "Mydata.backup"

Der Fehler entsteht, weil -d bereits die Zieldatenbank festlegt und PostgreSQL für -f eine reine Ausgabedatei vorsieht – beides zusammen ist widersprüchlich. Details im Handbuch: https://www.postgresql.org/docs/current/static/app-pgrestore.html