postgresql dblink使用

来源:互联网 发布:希区柯克剧场 知乎 编辑:程序博客网 时间:2024/04/30 16:59
配置过程相对简单,如下postgres=# create database test;CREATE DATABASEpostgres=# \c testYou are now connected to database "test" as user "postgres".test=# create extension dblink ;CREATE EXTENSIONtest=# \c postgres You are now connected to database "postgres" as user "postgres".postgres=# create table a (id int);CREATE TABLEpostgres=# insert into a select generate_series (1,5);INSERT 0 5postgres=# \c You are now connected to database "postgres" as user "postgres".postgres=# \c testYou are now connected to database "test" as user "postgres".test=# select dblink_connect('postgres_dblink','dbname=postgres host=localhost port=5432 user=postgres '); dblink_connect ---------------- OK(1 row)test=# select * from dblink ('postgres_dblink','select *  from a') as t1(id int); id ----  1  2  3  4  5(5 rows)test=# 

0 0
原创粉丝点击