0

In postgres 9.5 , I have a db called test. where I have 2 schemas 1.public 2. testcase when i try to restore tables from public to testcase shema. I creates duplicates in public schema and I couldn't view even a single table in testcase schema aftre the restoration. But it doesn't shows any error

learner
  • 1
  • 4
  • what you call duplicates?.. rows that "break" PK?.. – Vao Tsun Feb 11 '18 at 13:18
  • My status is,I have taken backup (.backup) from pubic schema and restored that in to another schema (from the same db) .when i do this all the tables (without any constrains such as uniqueId / primarykey) insert one more row from the backup file in the public schema. also I couldn't see any tables in my new schema . But restoration done without any errors. Why this – learner Feb 11 '18 at 13:29
  • please elaborate the post. add code, errors and precise actions list – Vao Tsun Feb 11 '18 at 13:32
  • *********DB*********** – learner Feb 11 '18 at 14:00
  • *******************db- test************shcemas-public,test2,tets3*******public-table1,table2,table3************* – learner Feb 11 '18 at 14:07
  • I just backuped the public schema and backuped all the 3tables and restored it to an empty schema called"test2" – learner Feb 11 '18 at 14:08
  • But unfortunately I had 1 table with no cosntraints like priary key or unique key. That is table1. so when I did this restoration to test2 , the data in the table1 duplicated by simply restored the data from backup file. – learner Feb 11 '18 at 14:12
  • this is meant behaviour. Postgres does not "analyze" backup file before restoring (because it can't guess, how exactly you want to restore the data). you could use -c `clean` if you used `pg_restore`, so it would `DROP` and recreate table before loading data. If you wanted PITR recover - you should use different approach. – Vao Tsun Feb 11 '18 at 14:49
  • the behavious is if I restore a backup from public schema to any other schema , it is restored to public schema too. is that mean i am doing something wrong here. I am using Dbeaver GUI for this. Not commands – learner Feb 11 '18 at 16:24
  • ah - I see. I have no idea how Dbeaver GUI does it. sorry. when you dont mention the backup command I assume you use pg_dump. – Vao Tsun Feb 11 '18 at 17:11
  • If you dont mind can you pls tell me the cokmands for both operations. taking public schema backup and restore to a particular schema. – learner Feb 11 '18 at 17:43
  • https://stackoverflow.com/questions/4191653/i-want-to-restore-the-database-with-a-different-schema – Vao Tsun Feb 11 '18 at 17:59
  • Thankzz a lot bro – learner Feb 11 '18 at 18:11
  • I hav edone the restoration using commands. but it doesn't show m,y tables in the new schema. – learner Feb 15 '18 at 02:28

0 Answers0