1

I have a simple model in postgresql database and I want to replicate rows of this table in another database in another machine.

The replication should be for some columns of this table and not for all columns.

What is the solution?

2 Answers 2

1

If by replication you mean import, look into foreign data wrappers:

http://wiki.postgresql.org/wiki/Foreign_data_wrappers

One of them ought to do the trick.

If you truly mean replication, then… if the other DB is not using Postgres, you could imagine using the above and triggers to keep the changes in sync, assuming of course that Postgres remains the master. If it is using Postgres, there are plenty of additional options to choose from:

http://www.postgresql.org/docs/current/static/high-availability.html

Sign up to request clarification or add additional context in comments.

4 Comments

I mean replication but I want to know is not there any other way maybe something like extension for this purpose?
Your question isn't clear on whether you need it from Postgres to Postgres (in which case cursory googling should yield multitudes of solutions, including some built-in ones) or, as I've assumed in my answer, Postgres to another database engine (in which case fdw is likely the way to go).
I need postgres to postgres
In that case there are more than a few options, no? wiki.postgresql.org/wiki/…
0

Take a look at the db_link module. You could try something like:

create extension dblink;

then once you have that installed:

select dblink_connect('myconn', 'hostaddr=127.0.0.1 port=5432 dbname=gis user=ubuntu password=ubuntu');
create table some_columns_table as select * from dblink('myconn','select col1, col2 from all_columns_table') AS t(col1 int, col2 text, col3 text);
select dblink_disconnect('myconn);

1 Comment

I need replication not db_link.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.