1.找到Postgresql安装目录/share/contrib

2.在目录中找到dblink.sql,执行这个文件里的SQL语句.

3.

与远程服务器建立一个连接:

select dblink_connect('db_name','dbname=db_name host=192.168.1.1 user=postgres password=123456');

通过这个连接访问那台数据库:

select * from dblink('db_name','SELECT id, name FROM test') as test(id integer, name character varying(50));

 

数据库内容:

CREATE TABLE test
(
  id serial NOT NULL,
  "name" character(50),
  CONSTRAINT id PRIMARY KEY (id)
)
WITH (OIDS=FALSE);
ALTER TABLE test OWNER TO postgres;

 

相关文章:

  • 2023-04-02
  • 2022-12-23
  • 2021-12-22
  • 2021-08-02
  • 2021-09-17
  • 2022-01-02
猜你喜欢
  • 2021-11-22
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-30
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案