查询操作
create extension dblink;
drop view view_remote_tb1;
CREATE VIEW view_remote_tbl_version AS
select * from
dblink('dbname=imos host=207.101.67.94 port=5432 user=postgres password=passwd'::text,'select * from tbl_version'::text)t
(autid bigint,version_type varchar, inner_version varchar, outer_version varchar);
--注意,此处的参数与tbl_version的参数一致
select * from view_remote_tbl_version ;
DML操作
select dblink_connect('myconn','dbname=zabbix host=207.101.67.94 port=5432 user=postgres password=passwd'::text);
SELECT dblink_exec('myconn', 'BEGIN');
SELECT dblink_exec('myconn', 'insert into test values(''A''),(''B'')');
SELECT dblink_exec('myconn', 'COMMIT');
SELECT dblink_disconnect('myconn');
结果: