0

I run this command

pg_dump mydatabase > backupfile

and after that delete some record from table in mydatabase and then run

psql mydatabase < backupfile

then in table occurred data redundancy problem.

GauravInno
  • 317
  • 1
  • 2
  • 14
  • use `--clean` in restore script !, Read the Postgres document : - http://www.postgresql.org/docs/9.4/static/app-pgrestore.html#APP-PGRESTORE-OPTIONS – Vivek S. Oct 08 '15 at 10:19
  • There are plenty of answers available for your question here is one of them : - http://stackoverflow.com/questions/10761073/how-to-restore-postgresql-dump-file-into-postgres-databases – Vivek S. Oct 08 '15 at 10:27
  • What is your actual need?, what you want to do with the backup file ? – Vivek S. Oct 08 '15 at 11:11
  • I have some data in my database and I want to add some new related data from backup file, and I don't want redundancy in my database and want the distinct values. e.g. I have 5 entries in my 'database' that are........... '1',, '3', '4', '5', '6'......................... and in backup file there are 3 entries '1', '2', '3'........... and i want merge the both.......... and want result like, '1', '2','3', '4','5','6'................ please help – GauravInno Oct 08 '15 at 11:36
  • 1
    what comes to my mind is leave the actual DB as it is. Now create a new DB and restore your backup.So you can use `dbblink()` function to get values from one db from another, Using `dbblink()` you can get(`select`) desired value from restored DB and insert it to the actual DB or use `COPY` method to import desired rows as `.csv` file from backuped DB and export it to actual DB – Vivek S. Oct 08 '15 at 11:48
  • I'd use foreign data wrappers not dblink, but otherwise yes, that's the way to go. – Craig Ringer Oct 09 '15 at 04:39
  • foreign data wrappers but how ????? – GauravInno Oct 09 '15 at 06:18

0 Answers0