Skip to main content

Posts

Showing posts from March, 2018

ERROR: cross-database references are not implemented

You face this error while trying to query two tables from difference databases in Postgres, as Postgress is unlike SQL Server, you can't join two tables from different databases. Instead you may have One Database with Two different Schemas . Schemas group your data tables separately and give you the flexibility to query and join tables from across schemas in the same Database. So if you have DB1 and DB2, you need to move the tables in DB2 to DB1 but in a new schema. If you are using the public schema in DB2 you need to change the name:   alter schema public rename to new_schema_name ; create schema public ;   Now Backup your Schema: $ pg_dump --format custom --file "my_backup" --schema " new_schema_name " "db2" $ pg_restore --dbname "db1" "my_backup" Your Done. If you have any question please let me know.