广告
返回顶部
首页 > 资讯 > 数据库 >怎么使用PostgreSQL contrib中的dblink插件
  • 1159
分享到

怎么使用PostgreSQL contrib中的dblink插件

2024-04-02 19:04:59 1159人浏览 独家记忆
摘要

这篇文章主要介绍“怎么使用postgresql contrib中的dblink插件”,在日常操作中,相信很多人在怎么使用Postgresql contrib中的dblink插件问题上存在疑惑,小编查阅了各式

这篇文章主要介绍“怎么使用postgresql contrib中的dblink插件”,在日常操作中,相信很多人在怎么使用Postgresql contrib中的dblink插件问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”怎么使用PostgreSQL contrib中的dblink插件”的疑惑有所帮助!接下来,请跟着小编一起来学习吧!

该插件可用于连接远程PG数据库,看起来像是oracle的DBLink.

安装
进入dblink目录,make & make install

[root@localhost contrib]# cd dblink/
[root@localhost dblink]# ls
dblink--1.0--1.1.sql  dblink--1.1--1.2.sql  dblink--1.2.sql  dblink.c  dblink.control  dblink--unpackaged--1.0.sql  expected  input  Makefile  output  pg_service.conf  sql
[root@localhost dblink]# 
[root@localhost dblink]# make
make -C ../../src/backend generated-headers
make[1]: Entering directory `/data/source/postgresql-12beta1/src/backend'
make -C catalog distprep generated-header-symlinks
make[2]: Entering directory `/data/source/postgresql-12beta1/src/backend/catalog'
make[2]: Nothing to be done for `distprep'.
make[2]: Nothing to be done for `generated-header-symlinks'.
make[2]: Leaving directory `/data/source/postgresql-12beta1/src/backend/catalog'
make -C utils distprep generated-header-symlinks
make[2]: Entering directory `/data/source/postgresql-12beta1/src/backend/utils'
make[2]: Nothing to be done for `distprep'.
make[2]: Nothing to be done for `generated-header-symlinks'.
make[2]: Leaving directory `/data/source/postgresql-12beta1/src/backend/utils'
make[1]: Leaving directory `/data/source/postgresql-12beta1/src/backend'
make -C ../../src/interfaces/libpq all
make[1]: Entering directory `/data/source/postgresql-12beta1/src/interfaces/libpq'
make -C ../../../src/port all
make[2]: Entering directory `/data/source/postgresql-12beta1/src/port'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `/data/source/postgresql-12beta1/src/port'
make -C ../../../src/common all
make[2]: Entering directory `/data/source/postgresql-12beta1/src/common'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `/data/source/postgresql-12beta1/src/common'
make[1]: Leaving directory `/data/source/postgresql-12beta1/src/interfaces/libpq'
GCc -std=gnu99 -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-fORMat-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -g -O0 -DOPTIMIZER_DEBUG -g3 -gdwarf-2 -fPIC -I../../src/interfaces/libpq -I. -I. -I../../src/include  -D_GNU_SOURCE -I/usr/include/libxml2   -c -o dblink.o dblink.c -MMD -MP -MF .deps/dblink.Po
gcc -std=gnu99 -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -g -O0 -DOPTIMIZER_DEBUG -g3 -gdwarf-2 -fPIC -shared -o dblink.so dblink.o  -L../../src/port -L../../src/common -L../../src/interfaces/libpq -lpq   -Wl,--as-needed -Wl,-rpath,'/appdb/xdb/pg12beta1/lib',--enable-new-dtags  
[root@localhost dblink]# make install
make -C ../../src/backend generated-headers
make[1]: Entering directory `/data/source/postgresql-12beta1/src/backend'
make -C catalog distprep generated-header-symlinks
make[2]: Entering directory `/data/source/postgresql-12beta1/src/backend/catalog'
make[2]: Nothing to be done for `distprep'.
make[2]: Nothing to be done for `generated-header-symlinks'.
make[2]: Leaving directory `/data/source/postgresql-12beta1/src/backend/catalog'
make -C utils distprep generated-header-symlinks
make[2]: Entering directory `/data/source/postgresql-12beta1/src/backend/utils'
make[2]: Nothing to be done for `distprep'.
make[2]: Nothing to be done for `generated-header-symlinks'.
make[2]: Leaving directory `/data/source/postgresql-12beta1/src/backend/utils'
make[1]: Leaving directory `/data/source/postgresql-12beta1/src/backend'
make -C ../../src/interfaces/libpq all
make[1]: Entering directory `/data/source/postgresql-12beta1/src/interfaces/libpq'
make -C ../../../src/port all
make[2]: Entering directory `/data/source/postgresql-12beta1/src/port'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `/data/source/postgresql-12beta1/src/port'
make -C ../../../src/common all
make[2]: Entering directory `/data/source/postgresql-12beta1/src/common'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `/data/source/postgresql-12beta1/src/common'
make[1]: Leaving directory `/data/source/postgresql-12beta1/src/interfaces/libpq'
/usr/bin/mkdir -p '/appdb/xdb/pg12beta1/lib/postgresql'
/usr/bin/mkdir -p '/appdb/xdb/pg12beta1/share/postgresql/extension'
/usr/bin/mkdir -p '/appdb/xdb/pg12beta1/share/postgresql/extension'
/usr/bin/install -c -m 755  dblink.so '/appdb/xdb/pg12beta1/lib/postgresql/dblink.so'
/usr/bin/install -c -m 644 ./dblink.control '/appdb/xdb/pg12beta1/share/postgresql/extension/'
/usr/bin/install -c -m 644 ./dblink--1.2.sql ./dblink--1.1--1.2.sql ./dblink--1.0--1.1.sql ./dblink--unpackaged--1.0.sql  '/appdb/xdb/pg12beta1/share/postgresql/extension/'
[root@localhost dblink]#

简介
dblink可以让PG具备在远程数据库上执行查询的能力,其语法如下:

dblink(text connname, text sql [, bool fail_on_error]) returns setof record
dblink(text connstr, text sql [, bool fail_on_error]) returns setof record
dblink(text sql [, bool fail_on_error]) returns setof record

其中,输入参数:connname为连接名称,connstr是连接串,sql为查询语句,fail_on_error标记出现错误是否停止;输出参数是产生的行,Record类型.由于返回没有列信息,因此使用时需指定columns信息.

使用
远程PG数据库部署在26.26上,希望在PG中查询该26.26实例testdb数据库public模式下的t1表.

testdb=# select * from t1;
 id 
----
  1
(1 row)
testdb=# \d+ t1
                                    Table "public.t1"
 Column |  Type   | Collation | Nullable | Default | Storage | Stats target | Description 
--------+---------+-----------+----------+---------+---------+--------------+-------------
 id     | integer |           |          |         | plain   |              | 
testdb=# select * from t1;
 id 
----
  1
(1 row)

在本机执行以下查询:

testdb=# create extension dblink;
CREATE EXTENSION
testdb=# select t1.* from dblink('host=192.168.26.26 port=5432 dbname=testdb user=xdb','select * from t1') as t1(id int);
 id 
----
  1
(1 row)

由于需要显式的指定的返回数据行的元数据,使用起来有些啰嗦.

到此,关于“怎么使用PostgreSQL contrib中的dblink插件”的学习就结束了,希望能够解决大家的疑惑。理论与实践的搭配能更好的帮助大家学习,快去试试吧!若想继续学习更多相关知识,请继续关注编程网网站,小编会继续努力为大家带来更多实用的文章!

您可能感兴趣的文档:

--结束END--

本文标题: 怎么使用PostgreSQL contrib中的dblink插件

本文链接: https://www.lsjlt.com/news/63793.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
  • 怎么使用PostgreSQL contrib中的dblink插件
    这篇文章主要介绍“怎么使用PostgreSQL contrib中的dblink插件”,在日常操作中,相信很多人在怎么使用PostgreSQL contrib中的dblink插件问题上存在疑惑,小编查阅了各式...
    99+
    2022-10-18
  • PostgreSQL中怎么使用pg_prewarm插件
    这篇文章主要介绍“PostgreSQL中怎么使用pg_prewarm插件”,在日常操作中,相信很多人在PostgreSQL中怎么使用pg_prewarm插件问题上存在疑惑,小编查阅了各式资料,整理出简单好用...
    99+
    2022-10-18
  • 怎么使用PostgreSQL的插件pgmetries
    这篇文章主要介绍“怎么使用PostgreSQL的插件pgmetries”,在日常操作中,相信很多人在怎么使用PostgreSQL的插件pgmetries问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操...
    99+
    2022-10-18
  • 怎么使用PostgreSQL的插件postgresql_anonymizer
    本篇内容主要讲解“怎么使用PostgreSQL的插件postgresql_anonymizer”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“怎么使用Postgr...
    99+
    2022-10-18
  • 怎么安装使用PostgreSQL中pageinspcet插件
    本篇内容主要讲解“怎么安装使用PostgreSQL中pageinspcet插件”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“怎么安装使用PostgreSQL中p...
    99+
    2022-10-19
  • PostgreSQL中怎么利用dblink实现跨库查询
    这期内容当中小编将会给大家带来有关PostgreSQL中怎么利用dblink实现跨库查询,文章内容丰富且以专业的角度为大家分析和叙述,阅读完这篇文章希望大家可以有所收获。一开始研究知道了sql语句的写法,但...
    99+
    2022-10-18
  • PostgreSQL中怎么利用DBLink实现自治事务
    本篇文章给大家分享的是有关PostgreSQL中怎么利用DBLink实现自治事务,小编觉得挺实用的,因此分享给大家学习,希望大家阅读完这篇文章后可以有所收获,话不多说,跟着小编一起来看看吧。安装dblink...
    99+
    2022-10-18
  • 怎么通过mysql的federated插件实现dblink功能
    这篇文章主要讲解了“怎么通过mysql的federated插件实现dblink功能”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“怎么通过mysql的fede...
    99+
    2022-10-18
  • 怎么安装PostgreSQL的插件pg_catcheck
    这篇文章主要讲解了“怎么安装PostgreSQL的插件pg_catcheck”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“怎么安装PostgreSQL的插件...
    99+
    2022-10-18
  • PostgreSQL的插件pg_variables有什么作用
    本篇内容主要讲解“PostgreSQL的插件pg_variables有什么作用”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“PostgreSQL的插件pg_va...
    99+
    2022-10-18
  • Oracle中建立了dblink怎么使用
    Oracle应用服务器OS   1.查看数据库的global_name SELECT * FROM GLOBAL_NAME; ...
    99+
    2022-10-18
  • Elasticsearch中的Head插件怎么使用
    本篇内容主要讲解“Elasticsearch中的Head插件怎么使用”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“Elasticsearch中的Head插件怎么使用”吧!Elasticsearc...
    99+
    2023-06-27
  • 怎么使用PostgreSQL中的benchmarksql
    这篇文章主要介绍“怎么使用PostgreSQL中的benchmarksql”,在日常操作中,相信很多人在怎么使用PostgreSQL中的benchmarksql问题上存在疑惑,小编查阅了各式资料,整理出简单...
    99+
    2022-10-18
  • vue的插件怎么使用
    本篇内容主要讲解“vue的插件怎么使用”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“vue的插件怎么使用”吧! vue的插件是为应用...
    99+
    2022-10-19
  • goland中怎么使用leetcode插件
    今天小编给大家分享一下goland中怎么使用leetcode插件的相关知识点,内容详细,逻辑清晰,相信大部分人都还太了解这方面的知识,所以分享这篇文章给大家参考一下,希望大家阅读完这篇文章后有所收获,下面我们一起来了解一下吧。安装使用步骤:...
    99+
    2023-07-06
  • Myeclipse中怎么使用axis插件
    要在MyEclipse中使用Axis插件,您可以按照以下步骤进行操作:1. 打开MyEclipse,并进入“Window”菜单,选择...
    99+
    2023-08-23
    Myeclipse axis
  • vue中elementUI里的插件怎么使用
    这篇文章主要讲解了“vue中elementUI里的插件怎么使用”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“vue中elementUI里的插件怎么使用”吧!全屏插件的引用全屏功能可以使用插件...
    99+
    2023-07-02
  • 使用python怎么往Postgresql数据库中插入一个Null值
    使用python怎么往Postgresql数据库中插入一个Null值?很多新手对此不是很清楚,为了帮助大家解决这个难题,下面小编将为大家详细讲解,有这方面需求的人可以来学习下,希望你能有所收获。python是什么意思Python是一种跨平台...
    99+
    2023-06-07
  • a.vim插件怎么使用
    本篇内容介绍了“a.vim插件怎么使用”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!A.vim如果你一直用像 C、C++ 这样的语言进行开发...
    99+
    2023-06-27
  • validationEngine插件怎么使用
    validationEngine插件是一个用于表单验证的jQuery插件,可以用于验证表单的输入内容是否符合要求。下面是使用vali...
    99+
    2023-08-19
    validationEngine
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作