问题描述
因此,我刚开始使用 dblink
,我刚刚创建了一个脚本,该脚本可将数据从另一个数据库插入到表中。我收到错误函数dblink(未知,未知)不存在
。
So I'm new to using dblink
, I just created a script that inserts data into a table from another database. I received the error function dblink(unknown,unknown) does not exist
.
所以我在线检查并使用创建扩展dblink
,最终得到此消息扩展 dblink已存在
。
So I checked online, and used CREATE EXTENSION dblink
, ended up getting this message extension "dblink" already exists
.
我的数据库链接代码是这样的:
My dblink code is like this:
INSERT INTO tableA
SELECT tbl.colA,tbl.colB,...
FROM dblink('dbname=anotherDB', 'SELECT colA,colB,...
FROM tableB')
as tbl(colA,colB,...)
推荐答案
查看扩展安装在哪个架构中。在我的情况下,此架构为 ext
:
Check out in which schema the extension is installed. In my case this schema is ext
:
select nspname as schema
from pg_extension e
join pg_namespace n on n.oid = e.extnamespace
where extname = 'dblink'
schema
--------
ext
(1 row)
将架构名称添加到搜索路径,例如:
Add the schema name to the search path, e.g.:
set search_path to public, ext;
或使用函数的合格名称 dblink()
,例如:
or use the qualified name of the function dblink()
, e.g.:
INSERT INTO tableA
SELECT tbl.colA,tbl.colB,...
FROM ext.dblink('dbname=anotherDB', 'SELECT colA,colB,...
FROM tableB')
as tbl(colA,colB,...)
这篇关于即使扩展名已经存在,dblink也不存在?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!