即使扩展已存在,dblink也不存在?

时间:2017-10-04 05:12:45

标签: postgresql insert dblink

所以我是使用Clone-Tree(root) if(root) == null return null if(root.children.length == 0) //Check if node is a Leaf if(root.selected) return Clone-Node(root) // Keep this node else return null; // Ignore the node bool AnyChildSelected = false parent = Clone-Node(root) for(i : 1 to children.Length) var childSelectedNode = Clone-Tree(children[i]) if(childSelectedNode != null) AnyChildSelected = true parent.AddChild(childSelectedNode) // Add child to new parent if(AnyChildSelected == true || root.selected == true) // Keep the node return parent else return null; // Ignore the node 的新手,我刚创建了一个脚本,可以将数据从另一个数据库插入到表中。我收到了错误dblink

所以我在网上查了一下,并使用了function dblink(unknown,unknown) does not exist,最后收到了此消息CREATE EXTENSION dblink

我的dblink代码是这样的:

extension "dblink" already exists

1 个答案:

答案 0 :(得分:4)

查看扩展程序安装在哪个架构中。就我而言,这个架构是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) 

将架构名称添加到搜索路径中,例如:

set search_path to public, ext;

或使用函数dblink()的限定名称,例如:

INSERT INTO tableA
 SELECT tbl.colA,tbl.colB,...
 FROM ext.dblink('dbname=anotherDB', 'SELECT colA,colB,...
                 FROM tableB')
as tbl(colA,colB,...)