如何在Postgres 8.4中导入模块或安装扩展? [英] How do I import modules or install extensions in Postgres 8.4?
问题描述
我正在尝试导入与8.4.1 postgres捆绑在一起的几个模块,并且所有这样做的命令(例如contrib.import等)都不起作用或找不到。请帮助我。
I'm trying to import several modules that come bundled with 8.4.1 postgres, and all the commands to do so (such as contrib.import etc) do not work or cannot be found. Please help me.
推荐答案
在Ubuntu上安装PostgreSQL contrib
模块或Kubuntu(或类似的Linux发行版):
To install PostgreSQL contrib
modules on Ubuntu or Kubuntu (or similar Linux distributions):
- 安装contrib包:
sudo apt-get install postgresql-contrib
- 重启数据库:
sudo /etc/init.d/postgresql-8.4 restart
- 更改为数据库所有者帐户(例如,
postgres
)。 - 切换到contrib模块的目录:
/usr/share/postgresql/8.4/contrib /
-
使用
ls
查看以下模块的列表:
- Install the contrib package:
sudo apt-get install postgresql-contrib
- Restart the database:
sudo /etc/init.d/postgresql-8.4 restart
- Change to the database owner account (e.g.,
postgres
). - Change to the contrib modules' directory:
/usr/share/postgresql/8.4/contrib/
Use
ls
to see a list of the following modules:
adminpack autoinc
btree_gin btree_gist
chkpass citext
cube dblink
dict_int dict_xsyn
earthdistance fuzzystrmatch
hstore insert_username
int_aggregate isn
lo ltree
moddatetime pageinspect
pg_buffercache pgcrypto
pg_freespacemap pgrowlocks
pg_stat_statements pgstattuple
pg_trgm pgxml
refint seg
sslinfo tablefunc
test_parser timetravel
tsearch2 uuid-ossp
使用以下命令加载SQL文件:
psql - U user_name -d database_name -f module_name.sql
例如,如果您的管理用户名为 postgres
,您的数据库名为 storage
,您想要的模块是 cube
,你输入:
For example, if your administrative user was named postgres
and your database was named storage
and the module you wanted was cube
, you would type:
psql -U postgres -d storage -f cube.sql
PostgresSQL 9.1:
在上面的步骤#1之后,执行:
PostgresSQL 9.1:
After step #1 above, do:
-
sudo /etc/init.d/postgresql restart
- (与上面#3相同)
-
cd /usr/share/postgresql/9.1/extension
(有扩展名) - 打开
psql
-
CREATE EXTENSIONuuid-ossp;
sudo /etc/init.d/postgresql restart
- (same as #3 above)
cd /usr/share/postgresql/9.1/extension
(has extensions)- open
psql
CREATE EXTENSION "uuid-ossp";
这篇关于如何在Postgres 8.4中导入模块或安装扩展?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!