Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- INSERT INTO localdb_image select * from
- dblink('host=10.1.1.1
- user=user
- password=password
- dbname=oat', 'SELECT e.* FROM image e JOIN archived f ON e.image_id=f.image_id AND e.dd=f.dd') tt(
- id int ,
- drive_id character varying(255) ,
- ) ;
- WHERE NOT EXISTS (SELECT 1 from localdb_image ei where ei.id = e.id)
- create materialized view mv_localdb_image as select * from
- dblink('host=10.1.1.1
- user=user
- password=password
- dbname=oat', 'SELECT e.* FROM image e JOIN archived f ON e.image_id=f.image_id AND e.dd=f.dd') tt(
- id int ,
- drive_id character varying(255) ,
- ) ;
- insert into localdb_image select * from mv_localdb_image mv where not exists (
- select 1 from localdb_image ii where ii.id=mv.id)
- -- pseudocode
- insert into localdb_image
- select *
- from dblink(...) tt (...)
- on conflict(id) do nothing;
Add Comment
Please, Sign In to add comment