问题描述
我通过MacPorts在笔记本电脑上安装了一个漂亮的PostgreSQL 9.0服务器.我想启用 hstore模块,但找不到安装这些模块的任何说明可选模块(我也无法在/opt/local/share/postgresql90/contrib/
中找到任何与hstore相关的代码).
I have a lovely PostgreSQL 9.0 server installed on my laptop via MacPorts. I would like to enable the hstore module, but I can't find any instructions for installing these optional modules (nor can I find any hstore-related code in /opt/local/share/postgresql90/contrib/
).
我已经找到了一些与hstore相关的SQL ,但是我不确定它来自哪里或与PostgreSQL 9.0是否兼容.
I have found some hstore-related SQL here, but I'm not sure where it comes from or if it's compatible w/ PostgreSQL 9.0.
那么,如何在安装MacPorts的Postgres 9.0服务器上启用hstore模块?
So, how do I enable the hstore module on my MacPorts-installed Postgres 9.0 server?
推荐答案
您可以告诉MacPorts构建hstore.就是这样.
You can tell MacPorts to build hstore. Here's how.
如果已经安装了postgresql
,则需要先将其卸载(这不会影响您的数据或用户),因为install
操作不会重新安装已经安装的端口.强制卸载(-f
)是因为postgresql91-server
是依赖的,并且将阻止卸载.
If you already have postgresql
installed, you will need to uninstall it first (this won't touch your data or users) because the install
action will not re-install an already installed port. The uninstall is forced (-f
) because postgresql91-server
is dependent and will prevent uninstall.
sudo port -f uninstall postgresql91
编辑Portfile并将hstore
添加到以set contribs
开头的行上的列表:
Edit the Portfile and add hstore
to the list on the line which begins with set contribs
:
sudo port edit postgresql91
(重新)从源文件中明确安装(-s
)以构建hstore扩展名:
(Re)install from source explicitly (-s
) to build the hstore extension:
sudo port -s install postgresql91
然后为每个要使用它的数据库加载一次hstore:
Then load hstore, once for each of your databases in which you want to use it:
在> = 9.1中:CREATE EXTENSION hstore;
In >= 9.1: CREATE EXTENSION hstore;
在9.0中:psql -U postgres -f /opt/local/share/postgresql90/contrib/hstore.sql
请注意,此过程仅将"92"替换为"91"即可用于postgresql92.
Note this process works for postgresql92 by just substituting "92" for "91".
这篇关于如何在PostgreSQL 9.0上安装hstore模块(安装MacPorts)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!