0

I have database a with schema foo which contains 20 tables. I want to move all of the contents of schema foo into database b without overriding the current content in database b.

Is there also a way to do it in pgadmin?

I found this link and perhaps it will be quite similar. But this particular link is for transferring a table. Copy a table from one database to another in Postgres

Chrisc
  • 13
  • 1
  • 1
  • 7

2 Answers2

0

You can script the first database with all its data once scripted you can run the th script within the other database it should work as long as you dont have tables in the second database with the same name

  • Any idea on how to do this? I've changed some of the values but this is what I get when I select CREATE script on pgadmin. I'm newer to scripts in SQL, so I dont want to accidentally override the contents of the other database. None of the tables in the second database have the same name. `CREATE DATABASE a_backup WITH OWNER = blank ENCODING = 'UTF8' LC_COLLATE = 'English_United States.122' LC_CTYPE = 'English_United States.122' TABLESPACE = pg_default CONNECTION LIMIT = -1;` – Chrisc Nov 01 '18 at 16:55
0

so in pg admin follow these steps to script the

-Right click on the database and click Backup. -Selece a filepath and filename on where you want to save your script -Select Plain as the format in the format dropdown. -Go to Options and check "schema and data" in tab # 1. -Then click on Backup. -Then click Done.

-Then right click on your 2nd database and create a new query. -Find where you saved the script and copy the script to the query -run the query and should be all good

if you are unsure about this just create 2 practice databases and practice on those before you do it on the main one

  • Thanks for your help and the tip of practicing on practice databases. Quick question, what version of pg_admin is this? I have the most recent update and under dump options there's a schema only and data only button. Can't do both. – Chrisc Nov 03 '18 at 21:21