Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8120119
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T05:01:18+00:00 2026-06-06T05:01:18+00:00

I am trying to link a remote database to a local database using dblink.

  • 0

I am trying to link a remote database to a local database using dblink. What want to achieve here is:

  1. I want to be fetching only data from the latest row(s) every 10 secs from a table in remote database.

  2. I wish to insert the data into a local database into a pre-existing table. In this case, I wish to insert the data I collected from the remote database, plus some others like primary key, and some sequenses which I dont get from the remote database into the table.

Any suggestions would be appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T05:01:21+00:00Added an answer on June 6, 2026 at 5:01 am
    • You’d need an indexed column in remote table that will increase every time a row will be inserted or updated there (not a timestamp, as many rows can have the same timestamp, a computer clock can sometimes go backwards etc.). If you don’t ever update then a serial primary key would suffice (enforce that updates are not allowed with a trigger if you decide to rely on this). Deletes would also not be synchronized, so I’d recommend to enforce that they’re not allowed using trigger too.

    • You’d need a cron (or scheduler on Windows) job that will connect to your database and perform synchronization, as PostgreSQL has no mechanism for periodic tasks.

    • This job would just do:

      start transaction;
      lock table local_tablename in exclusive mode;
      dblink_connect(…);
      insert into local_tablename (id, data, row_counter)
        select * from dblink(
          'select id, data, row_counter from remote_tablename
             where row_counter>'||(select coalesce(max(row_counter),-1) from local_tablename)
        ) as t(id int, data text, row_counter int);
      commit;

      It needs to be in transaction and protected with a lock, because it can break if it would run concurrently with another synchronization job (for example if previous job took more than 10 seconds).

      `coalesce` is needed in case `local_tablename` has no rows yet – it would then not insert anything without it. It assumes that always `row_counter>=0`.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to display some xml data from remote URL using jquery and
I'm trying to link two tables in the same database using a third. The
I have been trying to delete images from a remote server. I don't want
My Problem I am trying to load JSON encoded data from a remote site
I am trying to get some data from a database on the fly and
Im trying to link my program to the shared library. Im using a makefile
I am trying to link to an external link using the anchor tag like
i am trying to link a Unity game to a Java server using C#
I am trying to link up a redis database with a Node.js application I
I'm trying to link to an external stylesheet using this code: <?php include(/homepages/9/myusername/htdocs/Mobile_Detect.php); $detect

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.