Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

This can fall into the category of MSSQL USE database. I'm building a Postgres data warehouse for an existing transactional Postgres application. One of the main goals is to offload report generation bandwidth from the transactional application. Some reports require 20+ minutes to run. More of these are being built.

I've built several FDWs against the transactional database and several ETL sql scripts that populate various dimensions and facts. Joy. Now I'm versioning the scripts. Being new to Postgres, I expected to use the MSSQL USE database command so that I can separate the transactional sql maintenance scripts from the data warehouse maintenance scripts. Little did I know that Postgres' concept of USE doesn't really exist. It's more like schemas, etc. That's fine.

Here's my question. I need a separate data warehouse application that runs on another server. The build/maintenance scripts need to install the transactional app and the data warehouse. The transactional app will have access to the data warehouse reports. To me, this implies a separate database. What is the "Postgres" way to do the following:

USE dw
GO

CREATE SCHEMA bi;

CREATE FOREIGN TABLE mytable (id integer, ...
CREATE TABLE bi.mytable(...
etc.
share|improve this question
    
If you are using psql to run the script you are looking for the \connect command. –  a_horse_with_no_name Jun 25 at 13:46

1 Answer 1

Better solution would be to set up a live replica for read only queries.

https://wiki.postgresql.org/wiki/Streaming_Replication

Adding just another schema is not a scalable solution from memory or hard drive perspective.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.